Internet Direct (Indy) Version 9.0.2 Beta
|
procedure DoRequest(const AMethod: TIdHTTPMethod; AURL: string; const ASource: TStream; const AResponseContent: TStream); virtual;
AMethod is the TIdHTTPMethod value that identifies the request to be performed. AURL is the URL-encode location of the resource to be affected by the HTTP request. ASource is a TObject descendant containing the data for the HTTP request. ASource must be either a TStrings or a TStream descendant or an EIdObjectTypeNotSupported exception will be raised. AResponseContent is a TStream where the content for the HTTP response will be stored.
DoRequest will parse AURL into components to determine if the URL contains a user name and password that should be used for authenticating the Request. DoRequest also normalizes the value in AURL to conform to URI notation.
DoRequest will call Connect when the client is not already Connected, and can raise a EIdSSLProtocolReplyError when using HTTPS and the connection fails or a timeout occurs.
DoRequest sets the content length of the Request to the size of the stream specified in ASource for HTTP PUT or POST methods, or zero (0) when using other HTTP methods. DoRequest also updates headers and optional cookies for the Request. DoRequest calls OpenWriteBuffer prior to construct and sending the HTTP Request to accomodate HTTP servers which do not fully implement the HTTP Protocol, and calls CloseWriteBuffer to complete the write transaction.
DoRequest reads the HTTP Server Response for the HTTP Client Request. DoRequest repeatedly calls ReadLn to retrieve headers and ResponseText from the server, until the server returns a ResponseCode other 100 Continue. This allows the HTTP client to accomodate servers which do not fully implement HTTP 1.1, and respond with 100 Continue for HTTP GET and HEAD methods.
DoRequest detects an HTTP Response with Redirection that requires further action to fulfill the Request. When HandleRedirects is True, and the current number of Redirects is less than the value specified in RedirectMaximum, AResponseContent is cleared and the OnRedirect event handler is triggered. Use OnRedirect to close the connection if no further processing is desired for the HTTP Response. When HandleRedirects is False, or RedirectMaximum is exceeded, the OnRedirect event handler is still triggered. An EIdProtocolReplyError can be raised when the redirect action is not handled in the OnRedirect event handler.
DoRequest also triggers event handlers when the HTTP ResponseCode indicates that HTTP Server or Proxy Server authentication is required for the HTTP Response. If the authentication is handled by the OnAuthorization or OnProxyAuthorization event handlers, DoRequest is called to perform the authentication request.