Microsoft KB Archive/832985

= How to suppress an HTTP 100-Continue response from an IIS server =

PSS ID Number: 832985

Article Last Modified on 10/13/2004

-

The information in this article applies to:


 * Microsoft Internet Information Services 5.0
 * Microsoft Internet Information Services version 5.1

-





INTRODUCTION
Sometimes, you may want to suppress HTTP 100-Continue responses that come from a server that is running Microsoft Internet Information Services (IIS).

For example, when a client sends a POST request, IIS sends the HTTP 100-Continue response automatically, and then IIS checks the server configuration and NTFS File System permissions to verify that the POST can be accepted. IIS may then send an HTTP 401-Access Denied response. When some clients receive the HTTP 100-Continue response, the clients assume that they will receive an HTTP 200-OK response. Therefore, these clients never process the HTTP 401-Access Denied response. If the clients do not process the HTTP 401-Access Denied response, these clients may stop responding (hang) while the clients wait for the HTTP 200-OK response.

For another example, some applications may add cookies to the first HTTP response that is sent to clients. If the response is an HTTP 100-Continue response, the cookies are added to the HTTP 100-Continue response.

This behavior is not practical, and we may not be willing to use it, as per http://www.rfc-editor.org/rfc/rfc2616.txt : &quot;Unexpected 1xx status responses MAY be ignored by a user agent.&quot;

For example, if we tell the client Set-Cookie with 1xx status response, then the client may completely ignore that if it choses to.

Cookies can be added to an HTTP 200-OK response.



MORE INFORMATION
You can use the ISAPI filter sample C code that this article provides to suppress HTTP 100-Continue responses that come from the IIS server. After you compile the code into a DLL, you must load the filter in IIS.

Note You can use Microsoft Visual C++ to compile this code into a DLL.

IIS 5.0 and 5.1

 * 1) In IIS Manager, right-click the server name, and then click Properties.
 * 2) Click WWW Service, and then click Edit.
 * 3) Click the ISAPI Filters tab, and then click Add.
 * 4) In the Filter Properties dialog box, type the name of the filter in the Filter Name box, and then either type the path of the executable file or click Browse to locate the executable file.
 * 5) Restart IIS to load the filter.

IIS 6.0

 * 1) In IIS Manager, right-click Web Sites, and then click Properties.
 * 2) Click the ISAPI Filters tab, and then click Add.
 * 3) In the Filter Properties dialog box, type the name of the filter in the Filter Name box, and then either type the path of the executable file or click Browse to locate the executable file.

Code sample

 * 1) include 
 * 2) include 


 * 1) define VALUE_SIZE 32

BOOL WINAPI TerminateFilter( DWORD dwFlags ){return TRUE;}

BOOL WINAPI GetFilterVersion( HTTP_FILTER_VERSION * pVer  ) { pVer->dwFilterVersion = MAKELONG( 0, 4 );   // Version 4.0 pVer->dwFlags = SF_NOTIFY_SEND_RAW_DATA | SF_NOTIFY_SEND_RESPONSE | SF_NOTIFY_ORDER_HIGH; lstrcpy( pVer->lpszFilterDesc, &quot;clean100 filter version, v1.0&quot; ); return TRUE; }

DWORD WINAPI HttpFilterProc( HTTP_FILTER_CONTEXT *       pfc,  DWORD                       NotificationType,  VOID *                      pvData ) { CHAR    szValue[VALUE_SIZE] = &quot;&quot;; DWORD  cbValue = VALUE_SIZE; HTTP_FILTER_SEND_RESPONSE * pResponse = (HTTP_FILTER_SEND_RESPONSE *)pvData; HTTP_FILTER_RAW_DATA * pRawData = (HTTP_FILTER_RAW_DATA*)pvData;

switch ( NotificationType ) { case SF_NOTIFY_SEND_RESPONSE:

if ( 100 == pResponse->HttpStatus ) {     if ( ( !pfc->GetServerVariable( pfc,                                       &quot;HTTP_EXPECT&quot;,                                       szValue,                                       &cbValue ) )     ||           ( _stricmp( szValue, &quot;100-continue&quot; ) != 0 )         ) {       pfc->pFilterContext = (LPVOID)1; return SF_STATUS_REQ_NEXT_NOTIFICATION; }   }

pfc->pFilterContext = NULL; pfc->ServerSupportFunction( pfc,                               SF_REQ_DISABLE_NOTIFICATIONS,                                    NULL,                                    SF_NOTIFY_SEND_RAW_DATA,                                    0 ); break;

case SF_NOTIFY_SEND_RAW_DATA:

if ( pfc->pFilterContext ) {       pRawData->cbInData = 0; pfc->pFilterContext = NULL; } }

return SF_STATUS_REQ_NEXT_NOTIFICATION; }//--HttpFilterProc //END Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and the tools that are used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, visit the following Microsoft Web site:

http://directory.microsoft.com/resourcedirectory/Solutions.aspx

For additional information about the support options available from Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;%5BLN%5D;CNTACTMS

