CHttpServer::GetAllClientHeaders Method  
 
INT GetAllClientHeaders(
  UINT nClientId,  
  UINT nHeaderType,  
  LPTSTR lpszHeaders,  
  INT nMaxLength,  
);

Return all client request or response headers in a string buffer.

Parameters

nClientId
An unsigned integer which uniquely identifies the client session.
nHeaderType
Specifies the type of header. It may be one of the following values:
Constant Description
HTTP_HEADERS_REQUEST Return the value of a request header that was provided by the client. Request header values provide additional information to the server about the type of request being made.
HTTP_HEADERS_RESPONSE Return the value of a response header that was created by the server. Response header values provide additional information to the client about the type of information that is being returned by the server.
lpszHeaders
A pointer to a string buffer that will contain all of the client request or response headers when the method returns. Each header name is separated from its value by the colon (:) and each header is terminated with a carriage return and linefeed (CRLF) sequence. The end of the header block is terminated with a null character.
nMaxLength
An integer that specifies the maximum number of characters that can be copied into the header value buffer, including the terminating null character. If the lpszHeaders parameter is NULL, this value must be zero.

Return Value

If the method succeeds, the return value is the length of the complete header block, not including the terminating null character. If the client ID does not specify a valid client session, the method will return zero. If the lpszHeaders parameter is not NULL and the buffer is not large enough to store the complete header value, the method will return zero and the last error code will be set to ST_ERROR_BUFFER_TOO_SMALL. If the method fails, the GetLastError method will return more information about the last error that has occurred.

Remarks

Refer to Hypertext Transfer Protocol Headers for a list of common request and response headers that are used.

Example

LPTSTR lpszHeaders = NULL;

// Get the size of the complete header block
INT nLength = pServer->GetAllClientHeaders(nClientId, NULL, 0);

if (nLength > 0)
{
    // Allocate memory for the header block
    lpszHeaders = new TCHAR[nLength + 1];

    // Return a copy of all of the request headers
    pServer->GetAllClientHeaders(
        nClientId,
        HTTP_HEADERS_REQUEST,
        lpszHeaders,
        nLength + 1);
}

Requirements

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

See Also

DeleteClientHeader, GetClientHeader, SetClientHeader