Indy 9
TIdHTTPProtocol
Hierarchy, Properties, Methods, See Also, Unit: IdHTTP
Implements a HTTP protocol handler for connection and request/response processing.
TIdHTTPProtocol = class(TObject)
Unit
IdHTTP
Description
TIdHTTPProtocol is a TObject decendant that implements a HTTP protocol handler for an HTTP Request or HTTP Response. TIdHTTPProtocol is the type used to represent the internal protocol handler for TIdHTTP, and allows the client to perform state-dependant protocol exchanges used during client connection and servicing of the request/response chain.

TIdHTTPProtocol.Request
TIdHTTPProtocol, See Also
Represents HTTP request items used by the HTTP protocol handler.
property Request: TIdHTTPRequest;
Description
Request is a read-only TIdHTTPRequest property that represents the client connection and connection type, the HTTP method, the URL, and the input stream used by the HTTP protocol handler. The Request property is used in TIdHTTP.SetHeaders and TIdHTTP.SetCookies, and allows the protocol handler to provide the values used in a generated HTTP request to various event handlers in the TIdHTTP client.

TIdHTTPProtocol.Response
TIdHTTPProtocol, See Also
Represents HTTP response values captured by the HTTP protocol handler.
property Response: TIdHTTPResponse;
Description
Response is a read-only TIdHTTPResponse property that represents the HTTP client connection and connection flags, the numeric reponse code and text, and the content stream used by the HTTP protocol handler. The Response property is used in GetResponseHeaders, and allows the protocol handler to provide the values received in a HTTP response. Values in the Response property are updated using the RetrieveHeaders method when ConnectToHost or DoRequest is used.

TIdHTTPProtocol.BuildAndSendRequest
TIdHTTPProtocol, See Also
Constructs and sends a HTTP request message using headers and cookies.
procedure BuildAndSendRequest(AURI: TIdURI);
Parameters
AURI: TIdURI
Optional Universal Resource Locator for the request.
Description
BuildAndSendRequest is a procedure that allows the protocol handler to set header values for the HTTP request, and to send the request to the HTTP server. BuildAndSendRequest will insure that ProxyParams is updated from the raw headers in Request, and sets cookie values for the optional domain in AURI.

BuildAndSendRequest also generates the HTTP request message packet, including header values, and writes the values using the connection for the TIdHTTP client. BuildAndSendRequest is called from ConnectToHost.


TIdHTTPProtocol.Create
TIdHTTPProtocol, See Also
Constructor for the object instance.
constructor Create(AConnection: TIdCustomHTTP);
Description
Create is the constructor for the object instance. Create calls the inherited Create method to initialize the object instance. Create sets the internal member used to represent the TIdHTTP connection for the protocol handler. Create also allocates resources used to represent the Request and Response headers generated during HTTP protocol exchanges.

TIdHTTPProtocol.Destroy
TIdHTTPProtocol, See Also
Frees the object instance.
destructor Destroy; override;
Description
Destroy is the destructor for the object instance. Destroy frees resources allocted in the Create constructor, including Request and Response. Destroy calls the inherited Destroy method prior to exiting.

TIdHTTPProtocol.ProcessResponse
TIdHTTPProtocol, See Also
Handles the state-dependent processing of requests and responses for an HTTP client.
function ProcessResponse: TIdHTTPWhatsNext;
Description
ProcessResponse is a TIdHTTPWhatsNext function that allows the HTTP protocol handler to perform state-dependent protocol exchanges using the Request and Response properties. ProcessResponse is, in essence, the state machine used to control actions of a TIdHTTP client during connection and request/response processing.

ProcessResponse allows the protocol handler to detect and response to various conditions that include :

  • Redirection in a HTTP response.

  • Use of Keep-Alive for Secure Socket Layer transport.

  • HTTP Server and Proxy Server authorization.

  • Response content stream handling.

  • Exception processing.

ProcessResponse is used when the HTTP client attempts to connect to the remote server to perform an HTTP request or receive an HTTP response. The TIdHTTPWhatsNext return value for ProcessResponse is updated often during execution of the method based on the numeric HTTP result codes or exceptions encountered during the request/response protocol exchange.


TIdHTTPProtocol.RetrieveHeaders
TIdHTTPProtocol, See Also
Captures and processes headers in an HTTP response.
procedure RetrieveHeaders;
Description
RetrieveHeaders is a procedure that allows the HTTP protocol handler to read header values in an HTTP Response, and to store the raw headers in the Response for the protocol handler. RetrieveHeaders clears all headers in Response prior to reading new values.

RetrieveHeaders repeatedly calls ReadLn until no more header data is available on the HTTP client connection, or an EIdConnClosedGracefully is raised. If an exception is raised, the HTTP client connection is closed. When all headers have been read from the client, RetrieveHeaders calls Response.ProcessHeaders to move the read headers to their corresponding properties.


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