WriteServer callback function

Applies to: desktop apps only

The WriteServer callback function writes a data buffer to the server.

The WriteServer callback function is declared as:


BOOL WINAPI WriteServer(
  _In_  struct _HTTP_FILTER_CONTEXT *pfc,
  _In_  LPVOID Buffer,
  _In_  LPDWORD lpdwBytes,
  DWORD dwReserved


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

  • Buffer [in]
    Pointer to the buffer to write.

  • lpdwBytes [in]
    Pointer to the size of the buffer pointed to by the Buffer parameter.

  • dwReserved
    Reserved for future use.

Return value

This callback function returns TRUE if the call is successful; otherwise, it returns FALSE. To obtain extended error information, call GetLastError.


The WriteServer function can be called after an SF_NOTIFY_FORWARD_RAW_DATA notification is received until an SF_NOTIFY_END_OF_REQUEST notification is received. The WriteServer function should not be called before an SF_NOTIFY_FORWARD_RAW_DATA notification is received because there is no connection with the server. For more information about the types of event notifications that are sent to Web filters, see Event Notifications.

The WriteServer function is called through a pointer that is a member of the WPX_FILTER_CONTEXT structure. To get a pointer to the WPX_FILTER_CONTEXT structure for calling the WriteServer function from the pointer to the HTTP_FILTER_CONTEXT structure provided in the pfc parameter in the call to the HttpWPXFilterProc entry-point function (for an SF_NOTIFY_FORWARD_RAW_DATA notification), use the TO_WPX_FILTER_CONTEXT macro as follows:

if (pwfc != NULL) {

The WriteServer callback function is synchronous and blocks the thread from which it is called until the I/O operation is completed. A Web filter sending a large amount of data in calls to this function can block all of the available worker threads with a resultant denial of service (DoS).


Minimum supported client

None supported

Minimum supported server

Windows Server 2008 R2, Windows Server 2008 with SP2 (64-bit only)


Forefront Threat Management Gateway (TMG) 2010



See also

Callback Functions



Build date: 7/12/2010