CLlmClient::GetHeader Method  
 
INT GetHeader(
  LPCTSTR lpszHeaderName,  
  LPTSTR lpszHeaderValue,  
  INT nMaxLength  
);

The GetHeader method returns the value of an HTTP header from the server response.

Parameters

lpszHeaderName
A pointer to a null-terminated string which specifies the name of the HTTP response header. The header names are not case-sensitive. Header names may only contain ASCII letters, numbers and a restricted subset of punctuation characters. Header names cannot contain Unicode or ANSI multi-byte character sequences.
lpszHeaderValue
A pointer to a string buffer which will contain the header value when the method returns. If this parameter is NULL, the header value will not be copied and the method will return the length. If the buffer is not large enough to contain the entire header value, it will be truncated.
nMaxLength
An integer which specifies the maximum number of characters which can be copied into the lpszHeaderValue string buffer. If lpszHeaderValue is NULL, this value should be zero. The maximum length must include room for the terminating null character.

Return Value

If the method succeeds, the return value is the length of the header value in characters, not including the terminating null character. If the header is undefined or the method fails, the return value is zero. To get extended error information, call GetLastError. If the header field does not exist, the error code will be ST_ERROR_HEADER_NOT_FOUND.

Remarks

The GetHeader method returns the value of a response header from the last request made to the service provider.

This method is intended for applications that need lower-level access to provider-specific response headers. Most applications do not need to call this method. Standard response information, such as the HTTP status code, response text, token usage, model name, and elapsed time, is available through the API.

The headers returned by a service provider can vary depending on the provider, model, endpoint, account configuration, and the specific request being made. Applications should not assume that a particular header will always be present unless it is documented by the service provider.

If the header field specified by lpszHeaderName was not returned by the server, this method will return zero. If the lpszHeaderValue parameter is not NULL, it will contain an empty string when the method returns. The response headers are only available after a request has been sent to the server.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csllmv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also