Class TBrookHTTPResponse

Unit

Declaration

type TBrookHTTPResponse = class(TBrookHandledPersistent)

Description

Class which dispatches headers, contents, binaries, files and other data to the client.

Hierarchy

Overview

Methods

Public constructor Create(AHandle: Pointer); virtual;
Public destructor Destroy; override;
Public procedure SetCookie(const AName, AValue: string); virtual;
Public procedure Send(const AValue, AContentType: string; AStatus: Word); virtual;
Public procedure SendFmt(const AFormat: string; const AArgs: array of const; const AContentType: string; AStatus: Word); virtual;
Public procedure SendBinary(ABuffer: Pointer; ASize: NativeUInt; const AContentType: string; AStatus: Word); virtual;
Public procedure SendBytes(const ABytes: TBytes; ASize: NativeUInt; const AContentType: string; AStatus: Word); virtual;
Public procedure SendFile(ASize: NativeUInt; AMaxSize, AOffset: UInt64; const AFileName: TFileName; ADownloaded: Boolean; AStatus: Word); virtual;
Public procedure SendStream(AStream: TStream; AFreed: Boolean; AStatus: Word); overload; virtual;
Public procedure SendStream(AStream: TStream; AStatus: Word); overload; virtual;
Public procedure SendEmpty(const AContentType: string); overload; virtual;
Public procedure SendEmpty; overload; virtual;
Public procedure SendAndRedirect(const AValue, ADestination, AContentType: string; AStatus: Word); overload; virtual;
Public procedure SendAndRedirect(const AValue, ADestination, AContentType: string); overload; virtual;
Public procedure Download(const AFileName: TFileName; AStatus: Word); overload; virtual;
Public procedure Render(const AFileName: TFileName; AStatus: Word); overload; virtual;
Public procedure Download(const AFileName: TFileName); overload; virtual;
Public procedure Render(const AFileName: TFileName); overload; virtual;
Public procedure Reset; virtual;
Public procedure Clear; virtual;
Public function IsEmpty: Boolean;

Properties

Public property Compressed: Boolean read FCompressed write FCompressed;
Public property Headers: TBrookStringMap read FHeaders;
Public property Cookies: TBrookHTTPCookies read FCookies write SetCookies;
Public property Empty: Boolean read IsEmpty;

Description

Methods

Public constructor Create(AHandle: Pointer); virtual;

Creates an instance of TBrookHTTPResponse.

Parameters
AHandle[in]
Request handle.
Public destructor Destroy; override;

Frees an instance of TBrookHTTPResponse.

Public procedure SetCookie(const AName, AValue: string); virtual;

Sets server cookie to the response handle.

Parameters
AName[in]
Cookie name.
AValue[in]
Cookie value.
Public procedure Send(const AValue, AContentType: string; AStatus: Word); virtual;

Sends a string content to the client.

Parameters
AValue[in]
String to be sent.
AContentType[in]
Content type.
AStatus[in]
HTTP status code.
Public procedure SendFmt(const AFormat: string; const AArgs: array of const; const AContentType: string; AStatus: Word); virtual;

Sends a formatted string content to the client.

Parameters
AFmt[in]
Format string.
AArgs[in]
Arguments to compose the formatted string.
AContentType[in]
Content type.
AStatus[in]
HTTP status code.
Public procedure SendBinary(ABuffer: Pointer; ASize: NativeUInt; const AContentType: string; AStatus: Word); virtual;

Sends a binary content to the client.

Parameters
ABinary[in]
Binary content to be sent.
ASize[in]
Content size.
AContentType[in]
Content type.
AStatus[in]
HTTP status code.
Public procedure SendBytes(const ABytes: TBytes; ASize: NativeUInt; const AContentType: string; AStatus: Word); virtual;

Sends an array of Bytes content to the client.

Parameters
ABytes[in]
Array of Bytes to be sent.
ASize[in]
Content size.
AContentType[in]
Content type.
AStatus[in]
HTTP status code.
Public procedure SendFile(ASize: NativeUInt; AMaxSize, AOffset: UInt64; const AFileName: TFileName; ADownloaded: Boolean; AStatus: Word); virtual;

Sends a file to the client.

Parameters
ASize[in]
Size of the file to be sent. Use zero to calculate automatically.
AMaxSize[in]
Maximum allowed file size. Use zero for no limit.
AOffset[in]
Offset to start reading from in the file to be sent.
AFileName[in]
Path of the file to be sent.
ADownloaded[in]
If True it offers the file as download.
AStatus[in]
HTTP status code.
Public procedure SendStream(AStream: TStream; AFreed: Boolean; AStatus: Word); overload; virtual;

Sends a stream to the client.

Parameters
AStream[in]
Stream to be sent.
AFreed[in]
True frees the stream automatically as soon as it is sent.
AStatus[in]
HTTP status code.
Public procedure SendStream(AStream: TStream; AStatus: Word); overload; virtual;

Sends a stream to the client. The stream is freed automatically as soon as it is sent.

Parameters
AStream[in]
Stream to be sent.
AStatus[in]
HTTP status code.
Public procedure SendEmpty(const AContentType: string); overload; virtual;

Sends an HTTP status 204 to the client indicating the server has fulfilled the request, but does not need to return a content.

Parameters
AContentType[in]
Content type.
Public procedure SendEmpty; overload; virtual;

Sends an HTTP status 204 to the client indicating the server has fulfilled the request, but does not need to return a content.

Public procedure SendAndRedirect(const AValue, ADestination, AContentType: string; AStatus: Word); overload; virtual;

Sends a string content to the client and redirects it to a new location.

Parameters
AValue[in]
String to be sent.
ADestination[in]
Destination to which it will be redirected as soon as the content is sent.
AContentType[in]
Content type.
AStatus[in]
HTTP status code (must be >=300 and <=307).
Public procedure SendAndRedirect(const AValue, ADestination, AContentType: string); overload; virtual;

Sends a string content to the client with HTTP status 302 and redirects it to a new location.

Parameters
AValue[in]
String to be sent.
ADestination[in]
Destination to which it will be redirected as soon as the content is sent.
AContentType[in]
Content type.
Public procedure Download(const AFileName: TFileName; AStatus: Word); overload; virtual;

Offers a file as download.

Parameters
AFileName[in]
Path of the file to be sent.
AStatus[in]
HTTP status code.
Public procedure Render(const AFileName: TFileName; AStatus: Word); overload; virtual;

Sends a file to be rendered.

Parameters
AFileName[in]
Path of the file to be sent.
AStatus[in]
HTTP status code.
Public procedure Download(const AFileName: TFileName); overload; virtual;

Offers a file as download.

Parameters
AFileName[in]
Path of the file to be sent.
Public procedure Render(const AFileName: TFileName); overload; virtual;

Sends a file to be rendered.

Parameters
AFileName[in]
Path of the file to be sent.
Public procedure Reset; virtual;

Resets status and internal buffers of the response handle preserving all headers and cookies.

Public procedure Clear; virtual;

Clears all headers, cookies, status and internal buffers of the response object.

Public function IsEmpty: Boolean;

Checks if the response is empty.

Properties

Public property Compressed: Boolean read FCompressed write FCompressed;

Determines if the content must be compressed while sending. The compression is done by the ZLib library using the DEFLATE compression algorithm. It uses the Gzip format when the content is a file.

Public property Headers: TBrookStringMap read FHeaders;

Hash table containing the headers to be sent to the client.

Public property Cookies: TBrookHTTPCookies read FCookies write SetCookies;

Cookies to be sent to the client.

Public property Empty: Boolean read IsEmpty;

Determines if the response is empty.


Generated by PasDoc 0.16.0.