Partager via


AddHeader Function

The AddHeader callback function adds an HTTP header to the incoming request or outgoing response.

BOOL WINAPI * AddHeader(
   PHTTP_FILTER_CONTEXT pfc,
   LPSTR lpszName,
   LPSTR lpszValue
);

Parameters

  • pfc
    Points to the HTTP_FILTER_CONTEXT Structure that is associated with the current, active HTTP transaction.

  • lpszName
    Points to the name of the header to add.

  • lpszValue
    Points to the new string to change the header to or to \0 to delete the header.

Return Values

Returns true if the function was successful; otherwise false. The GetLastError function indicates the reason for failure. The most common reason is as follows:

Return code

Description

ERROR_INVALID_PARAMETER

If pfc or the server context that pfc points to is invalid. Additionally, if the header name does not end with a colon (:) or if the header contains either a carriage return ('\r') or line feed ('\n') character.

Remarks

This callback function is only available during notifications for the SF_NOTIFY_PREPROC_HEADERS event (via the HTTP_FILTER_PREPROC_HEADERS Structure (IIS) structure), the SF_NOTIFY_AUTH_COMPLETE event (via the HTTP_FILTER_AUTH_COMPLETE_INFO Structure (IIS) structure), and the SF_NOTIFY_SEND_RESPONSE event (via the HTTP_FILTER_SEND_RESPONSE Structure structure). All callback functions are limited in this manner.

The special values "method", "url", and "version" can be used in SF_NOTIFY_PREPROC_HEADERS or SF_NOTIFY_AUTH_COMPLETE to retrieve the individual portions of the request line. The special value "status" can be used in SF_NOTIFY_SEND_RESPONSE to retrieve the entire response line. The special values must not include the trailing colon and should be lower-case.

Requirements

Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.

Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.

Product: IIS

Header: Declared in httpfilt.h.