SetHeader Callback Function

The SetHeader callback function is used by Web filters to modify or delete the value of a header or to add a new header. The function can also be used to modify the special values included in the request or status line.

The SetHeader callback function is declared as:


BOOL WINAPI * SetHeader(
  __in  struct _HTTP_FILTER_CONTEXT* pfc,
  __in  LPSTR lpszName ,
  __in  LPSTR lpszValue 



Pointer to the HTTP_FILTER_CONTEXT data structure that is associated with the current, active HTTP session. Pass the filter context in this parameter.


Pointer to a null-terminated string containing the name of the header to modify or delete. Header names should include the trailing colon (:). This parameter is not case-sensitive.

The special values "method", "url", "version", and "body" (for requests only) can be used to set individual portions of the request line. When the value "body" is specified, the function sets the part of the body that has already been received.

The special value "status" can be used to set the status in the response line.

Note that the special values do not include a trailing colon.


Pointer to a null-terminated string containing the new string for the header, or to "\0" (if the header is to be deleted).

Return Value

This callback function returns TRUE if the call is successful; otherwise, it returns FALSE. To obtain extended error information, call GetLastError, which may return one of the following Windows system error codes:


The value specified in the lpszName parameter is not valid for the request.


The value specified in the lpszValue parameter is invalid. This error code is also returned after an SF_NOTIFY_AUTH_COMPLETE notification if the filter tries to modify the URL, method, or version portion of the request line.


Not enough memory was available to complete the requested operation.


The request is an HTTP 0.9 request, which contains no headers.


A pointer to this function is included as a member of the following structures:


Server Requires Windows Server 2008.
Version Requires Forefront Threat Management Gateway (TMG).

Declared in Wpxhttpfilt.h.


Requires W3Filter.dll.

See Also

Callback Functions

Send comments about this topic to Microsoft

Build date: 11/30/2009

© 2008 Microsoft Corporation. All rights reserved.