wwHTTP::HTTPGetHeader

Retrieves just the HTTP header from a URL. Useful for retrieving information about a request prior to actually downloading the full URL. You can spy the content length from the header for example.

In download scenarios, you might want to use the cHTTPHeaders property and the OnHTTPBufferUpdate() event to trap for the HTTP header as part of a running request. The first buffer grab returns the HTTP header.

The cHTTPHeaders property is also set by this method so passing in the 2nd and 3rd parameters is optional.

o.httpgetheader(tcPage, tcHeaders, tnHeaderSize)

Return Value

0 on success, an error number on failure

Parameters

tcPage
The Web relative page to access.

@tcHeaders
Buffer that will receive the headers. This buffer must be presized to the size that you expect and passed in by reference

@tnHeaderSize
Buffer that receives the byte size of the header returned. Pass by reference to retrieve the size of the result header.

Example

LOCAL loHttp as wwHTTP
loHttp=CREATEOBJECT("wwHTTP")

lcHeaders = loHttp.httpGetHeader("http://www.west-wind.com/")

IF EMPTY(lcHeaders)
   ? "Error occurred retrieving headers: " + loHttp.cErrorMsg
ENDIF

*** Full headers as property
? loHttp.cHttpHeaders

*** Or from return value
? lcHeaders

*** Retrieve a value using GetHttpHeader
? "Content Length: ",;
     loHttp.GetHttpHeader("Content-Length")

See also:

West Wind Web Connection

© West Wind Technologies, 1996-2024 • Updated: 06/16/11
Comment or report problem with topic