CHttpServer::SetClientHeader Method  
 
BOOL HttpSetClientHeader(
  UINT nClientId,  
  UINT nHeaderType,  
  LPCTSTR lpszHeaderName,  
  LPCTSTR lpszHeaderValue  
);

Create or change the value of a request or response header for the client session.

Parameters

nClientId
An unsigned integer which uniquely identifies the client session.
nHeaderType
Specifies the type of header to create or modify. It may be one of the following values:
Value Description
HTTP_HEADERS_REQUEST Change 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 Change 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.
lpszHeaderName
A null-terminated string that specifies the name of the header that should be created or modified. Header names are not case-sensitive and should not include the colon which acts as a delimiter that separates the header name from its value. This parameter cannot be a NULL pointer or an empty string.
lpszHeaderValue
A null-terminated string that specifies the new value of the header. If this parameter is a NULL pointer or an empty string, it has the same effect as deleting the header value from the list of request or response headers.

Return Value

If the method succeeds, the return value is non-zero. If the client ID does not specify a valid client session, the method will return zero. If the method fails, the GetLastError method will return more information about the last error that has occurred.

Remarks

The SetClientHeader method will change the value of a request or response header for the specified client session. If the lpszHeaderName value matches an existing header field, its value will be replaced. If the header name is not defined, then a new header will be created with the given value. You should not change the value of most standard response header values unless you are certain of the impact that it would have on the normal operation of the client.

If you wish to define a custom header value that would be included in the response to a client request, you should prefix the header name with "X-" to avoid potential conflicts with the standard response headers. For example, if you wanted to identify a customer, you could create a header field with the name "X-Customer-ID" and set the value to the customer ID number. The client application would receive this custom header value as part of the response to its request for a document.

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

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: cshtsv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also