Indy 9
TIdHTTPResponseInfo
Hierarchy, Properties, Methods, See Also, Unit: IdCustomHTTPServer
Implements a HTTP response object.
TIdHTTPResponseInfo = class(TIdResponseHeaderInfo)
Unit
IdCustomHTTPServer
Description
TIdHTTPResponseInfo is a TIdResponseHeaderInfo descendant that encapsulates access to information for a HTTP response. TIdHTTPResponseInfo is used by TIdHTTPServer to prepare a HTTP response for a peer thread request.

TIdHTTPResponseInfo publishes properties that provide access to various information for a HTTP response. These properties include the HTTP session, the authentication realm, Cookies, Headers, and the response content, length, and type.


TIdHTTPResponseInfo.AuthRealm
TIdHTTPResponseInfo
Identifies the authentication and encryption for the HTTP response.
property AuthRealm: string;
Description
AuthRealm is a String property that identifies the authentication and encryption scheme used for the HTTP response. AuthRealm is used in when constructing headers for TIdHTTPResponseInfo from property values. When AuthRealm contains a non-blank value, the HTTP response will include include a "WWW-Authenticate" header with the value "Basic realm=" and the quoted contents of the AuthRealm property. AuthRealm also insures that the ResponseNo for the HTTP Response is 401.

TIdHTTPResponseInfo.CloseConnection
TIdHTTPResponseInfo
Indicates if the HTTP response should contain a close connection header.
property CloseConnection: Boolean;
Description
CloseConnection is a Boolean property that indicates if the connection used for the HTTP response should remain open, or close after completed transmission of the the HTTP response. Changing the value in CloseConnection cause the value in Connection property to be updated for use in the generate connect header for the response. When CloseConnection contains True, the Connection property is given the value 'close'. Otherwise Connection is set to the value 'keep-alive'.

TIdHTTPResponseInfo.ContentStream
TIdHTTPResponseInfo, See Also
Specifies the stream that contains the content data.
property ContentStream: TStream;
Description
ContentStream is a TStream property that specifies the stream containing the content data for the HTTP response. WriteContent uses ContentStream, when assigned, to generate HTTP response content instead of ContentText.

TIdHTTPResponseInfo.ContentText
TIdHTTPResponseInfo, See Also
Specifies the content for the HTTP response.
property ContentText: string;
Description
ContentText is a String property that specifies the data used for the content of the HTTP response. WriteContent uses ContentStream, when assigned, to generate HTTP response content instead of ContentText.

TIdHTTPResponseInfo.Cookies
TIdHTTPResponseInfo, See Also
Identifies Cookies for the HTTP response.
property Cookies: TIdServerCookies;
Description
Cookies is a TIdServerCookies property that is a container for cookies values to be included in the HTTP response. Initial values for Cookies are assigned during execution of the client thread in TIdCustomHTTPServer when they are read from the HTTP request. Cookies is used to store the GSessionIDCookie that represents persistent state information for the HTTP session. Cookies is also used when headers for the HTTP response are constructed and written in TIdHTTPResponseInfo.WriteHeader.

TIdHTTPResponseInfo.FreeContentStream
TIdHTTPResponseInfo, See Also
Indicates if the object instance can free its ContentStream.
property FreeContentStream: Boolean;
Description
FreeContentStream is a Boolean property that indicates if the object instance can free the TStream resource allocated in ContentStream. FreeContentStream is set to True in the Create constructor, and insures that ContentStream will be released, if assigned prior to retrieving an HTTP response, in the Destroy method.

Under normal circumstances, FreeContentStream is not changed during the lifetime of the HTTP response. Set FreeContentStream to False when ContentStream is assigned manually, and the stream must continue to exist even after destruction of the HTTP response.


TIdHTTPResponseInfo.HeaderHasBeenWritten
TIdHTTPResponseInfo
Indicates that headers have been written in the HTTP response.
property HeaderHasBeenWritten: Boolean;
Description
HeaderHasBeenWritten ia Boolean property that indicates headers have already been written in the HTTP response. HeaderHasBeenWritten is used in WriteHeader to prevent duplication of header values for the HTTP response. HeaderHasBeenWritten is also checked when a threaded connection needs to write a HTTP response in the TIdHTTPServer.OnExecute event handler.

TIdHTTPResponseInfo.ResponseNo
TIdHTTPResponseInfo
Numeric response code for the HTTP response.
property ResponseNo: Integer;
Description
ResponseNo is an Integer property that indicates the numeric response code for the HTTP response. ResponseNo can contain one of the following numeric values, as defined in the HTTP protocol:

  • 200 - OK

  • 201 - Created

  • 202 - Accepted

  • 203 - Non-authoritative Information

  • 204 - No Content

  • 205 - Reset Content -

  • 206 - Partial Content

  • 301 - Moved Permanently

  • 302 - Moved Temporarily

  • 303 - See Other

  • 304 - Not Modified

  • 305 - Use Proxy

  • 400 - Bad Request

  • 401 - Unauthorized

  • 403 - Forbidden

  • 404 - Not Found

  • 405 - Method not allowed

  • 406 - Not Acceptable

  • 407 - Proxy Authentication Required

  • 408 - Request Timeout

  • 409 - Conflict

  • 410 - Gone

  • 411 - Length Required

  • 412 - Precondition Failed

  • 413 - Request Entity To Long

  • 414 - Request-URI Too Long. 256 Chars max

  • 415 - Unsupported Media Type

  • 500 - Internal Server Error

  • 501 - Not Implemented

  • 502 - Bad Gateway

  • 503 - Service Unavailable

  • 504 - Gateway timeout

  • 505 - HTTP version not supported

Use ResponseText for the textual respresentation of the HTTP response.


TIdHTTPResponseInfo.ResponseText
TIdHTTPResponseInfo
Represents the text for the response message.
property ResponseText: String;
Description
ResponseText is a String property used to represent the text portion of the HTTP response message. ResponseText normally contains on the of the following messages:

  • 200 - OK

  • 201 - Created

  • 202 - Accepted

  • 203 - Non-authoritative Information

  • 204 - No Content

  • 205 - Reset Content

  • 206 - Partial Content

  • 301 - Moved Permanently

  • 302 - Moved Temporarily

  • 303 - See Other

  • 304 - Not Modified

  • 305 - Use Proxy

  • 400 - Bad Request

  • 401 - Unauthorized

  • 403 - Forbidden

  • 404 - Not Found

  • 405 - Method not allowed

  • 406 - Not Acceptable

  • 407 - Proxy Authentication Required

  • 408 - Request Timeout

  • 409 - Conflict

  • 410 - Gone

  • 411 - Length Required

  • 412 - Precondition Failed

  • 413 - Request Entity To Long

  • 414 - Request-URI Too Long. 256 Chars max

  • 415 - Unsupported Media Type

  • 500 - Internal Server Error

  • 501 - Not Implemented

  • 502 - Bad Gateway

  • 503 - Service Unavailable

  • 504 - Gateway timeout

  • 505 - HTTP version not supported

Use ResponseNo for the numeric representation of the HTTP response.


TIdHTTPResponseInfo.ServerSoftware
TIdHTTPResponseInfo
Identifies the server software used to generate the HTTP response.
property ServerSoftware: string;
Description
ServerSoftware is a String property that identifies the server software used to generate the HTTP response. The default value for ServerSoftware is a string containing the values from GServerSoftware.

TIdHTTPResponseInfo.Session
TIdHTTPResponseInfo, See Also
Represents the session for the HTTP response.
property Session: TIdHTTPSession;
Description
Session is a read-only TIdHTTPSession property that represents the HTTP session used for the HTTP response. Session is assigned when the HTTP server calls CreateSession to get or create a persistent session for the client connection.

TIdHTTPResponseInfo.CloseSession
TIdHTTPResponseInfo, See Also
Closes an HTTP session and removes the session cookie.
procedure CloseSession;
Description
CloseSession is a procedure that closes a session in the session list for an HTTP server. CloseSession locates the session Cookie with the name specified in GSessionIDCookie, and removes the value from the Cookies collection. CloseSession also frees and release the Session maintained in the object instance.

CloseSession can be used to insure that an HTTP Server closes the session even when the session list is maintained.


TIdHTTPResponseInfo.Create
TIdHTTPResponseInfo, See Also
Constructor for the object instance.
constructor Create(AConnection: TIdTCPServerConnection); reintroduce;
Parameters
AConnection: TIdTCPServerConnection
The server connection for the HTTP response.
Description
Create is the constructor for the TIdHTTPResponseInfo object. Create is responsible for initializing the default values for properties in the instance. Create calls the inherited Create method.

Create sets ContentLength to the value specified in GFContentLength, and ContentType to the value in GContentType. The RawHeaders property is updated to avoid folding long lines for clients that may not support the feature. ServerSoftware is initialized to the values specified in GServerSoftware.

Create sets the connection used for the HTTP response to the TIdTCPServerConnection instance referenced in AConnection, and assigns to ResponseNo the default value from GResponseNo.

Create also allocates resources needed for the Cookies property.


TIdHTTPResponseInfo.Destroy
TIdHTTPResponseInfo
Frees the object instance.
destructor Destroy; override;
Description
Destroy is the destructor for the object instance. Destroy is responsible for releasing the object properties for the instance, including Cookies and ContentStream when a value has been assigned. Destroy calls the inherited destructor prior to exiting from the method.

TIdHTTPResponseInfo.Redirect
TIdHTTPResponseInfo
Updates the location for an HTTP response.
procedure Redirect(const AURL: string);
Parameters
const AURL: string
Location of the redirected resource.
Description
Redirect is a procedure that allows TIdHTTPResponseInfo to redirect the HTTP client to specific URL. Redirect sets ResponseNo to 302, the HTTP response code that indicates a temporary redirection has been performed. To indicate that a resource has been permanently moved, set ResponseNo to 301.

Redirect also updates the "Location" Header for the HTTP response to contain the value specified in AURL.


TIdHTTPResponseInfo.WriteContent
TIdHTTPResponseInfo, See Also
Generates the HTTP response content.
procedure WriteContent;
Description
WriteContent is a procedure used to generate the content for the HTTP response. WriteContent generates the content using either ContentText, or ContentStream when assigned, for ResponseNo values in the range 200 - 499 inclusive. If ResponseNo is not in this range, only the ResponseNo and ResponseText is included in the content of the HTTP response.

WriteContent uses Connection to transfer the content of the HTTP response to the HTTP client.

Use WriteHeader to generate header values prior to calling WriteContent.


TIdHTTPResponseInfo.WriteHeader
TIdHTTPResponseInfo, See Also
Generates headers for the HTTP response.
procedure WriteHeader;
Parameters
Dest
Destination stream used as a buffer for the headers. Default value is Nil.
Description
WriteHeader is a procedure used to generate HTTP headers for the HTTP response. WriteHeader will raise an EIdHTTPHeaderAlreadyWritten exception if HeaderHasBeenWritten indicates that HTTP headers have already been generated.

WriteHeader generates the following HTTP header values:

  • Content-Type

  • Content-Length

  • WWW-Authenticate

  • Set-Cookie

WWW-Authenticate is generated when AuthRealm contains a non-empty value. ResponseNo is set to 401 when AuthRealm is used.

Set-Cookie is generated for each value in Cookies.

Dest is an optional TStream used as a local buffer for header values. When Dest is not Nil, headers are written to Dest and not to Connection.

Use WriteContent to generate the content for the HTTP response.


Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.