http OnHeaderInfo event
Return to Introduction  Previous page  Next page
Applies to
acHTTP component.  

Declaration
type  
  TacHTTPHeaderInfoEvent = procedure(Sender: TObject; ErrorCode: Integer;  
    const RawHeadersCRLF, ContentType, ContentLanguage, ContentEncoding, Location: String;  
    ContentLength: Integer; Date, LastModified, Expires: TDateTime;  
    var ContinueDownload: Boolean) of object;  
 
property OnHeaderInfo: TacHTTPHeaderInfo;  

Description
The OnHeaderInfo event returns the headers the response from the HTTP server, before downloading the document content.  
 
You can write this event handler to receive all response headers and to decide whether you want to download the document. If you decided to NOT download it, simply set ContinueDownload parameter to False in the event handler.  
 
The acHTTP passes to the OnHeaderInfo event handler following parameters:  
ParametersMeaning  
ErrorCodethe status code of HTTP request (see the list of possible status codes);  
RawHeadersCRLFcontains ALL the headers reseived from the HTTP server in response to request, as plain text string, separated by CRLF characters (0D0A);  
ContentTypecontains the identifier of MIME-type of requested document. For more information about Internet media types, please read RFC 2045, 2046, 2047, 2048, and 2077. Check out also the Internet media type registry at ftp://ftp.iana.org/in-notes/iana/assignments/media-types;  
ContentLanguageidentifies a language of document content (if provided), or contains empty string if the language is not provided or not applicable for the type requested document;  
ContentEncodingidentifies the encoding method of requested document;  
ContentLengthdeterminates the size of document, if the document is binary file. Unfortunately most servers does not provide the content length for ASCII documents with "text/*" MIME-type, since their content can be generated dynamically by CGI programs;  
Locationdetermines the location from where the content is about to be downloaded (use this parameter to get the actual location of document in case if connection has been redirected by server to another location);  
Dateshows the date and time at which the HTTP response was originated;  
LastModifiedthe date and time at which the server belives the resource was last modified;  
Expiresthe date and time after which the resource should be considered outdated;  
ContinueDownloadused to interrupt the download process. If you don't want to continue download the requested file — set it to False.  

Notes
iiwarning All date/time values that passed to the OnHeaderInfo even handler, is already converted from the server's time to local time, taking in account the time zone and daylight bias. (The acHTTP uses InternetTimeToDateTime function to convert the string representation of date/time to TDateTime value.) To get unmodified string parameters — parse the raw headers provided by RawHeadersCRLF parameter  

See also
OnDone and OnRedirected events;  
Abort method;  
HTTP status codes.