SAMPLE: How to Override the Server Name in the Response Header Field (294735)
The information in this article applies to:
- Microsoft Internet Information Server 3.0
- Microsoft Internet Information Server 4.0
- Microsoft Internet Information Services 5.0
This article was previously published under Q294735 SUMMARY
Section 14 of the World Wide Web Consortium's Request for Comments (RFC) for HTTP (RFC 2616) describes the header field definitions that are returned by an HTTP/1.1-compliant server. Section 14.38 of RFC 2616 discusses the server header that is sent by the HTTP 1.1-compliant Web server. It includes a note abut making this a configurable setting within the server software.
Internet Information Server/Services does not allow this to be a configurable option, but this can be altered through an ISAPI filter.
ServerHeader.exe provides a sample Microsoft Visual C++ project (including sample code) for an ISAPI filter that provides this functionality.
MORE INFORMATION
Internet Server API (ISAPI) is a programming interface for Internet servers, in this case Internet Information Server/Services (IIS). ISAPI filters are able to intercept events during the retrieval, processing, and returning of a request sent to a Web server, thus giving the developer a way to handle these events before the server has the opportunity to.
In the sample code available through this article, the filter intercepts the headers before they are sent to the client and changes the server header to the string that exists in a registry key.
The filter does this by requesting notification of the SF_NOTIFY_SEND_RESPONSE event, and when that event occurs, it retrieves the string that you have configured for the ServerType.
The ServerType REG_SZ registry key is implemented solely for the purposes of this filter.
This is the registry key that is checked:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters]
"ServerType"="Custom Server String"
If is value is empty or does not exist, the filter does not alter the server string and just allows the server to continue to process the request.
Once the value is read from the registry, the SetHeader() API is used to override the server string. The following file is available for download from the Microsoft Download Center:
Release Date: Mar-28-2001
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.
The file ServerHeader.exe contains the following:
Serverheader.def | 145 bytes | ServerHeader.cpp | 4,236 bytes | ReadMe.txt | 1,649 bytes | ServerHeader.dsp | 4,458 bytes | ServerHeader.dsw | 547 bytes | ServerHeader.ncb | 33,792 bytes | ServerHeader.opt | 48,640 bytes | ServerHeader.plg | 913 bytes | servertype.reg | 330 bytes | StdAfx.cpp | 229 bytes | StdAfx.h | 802 bytes |
REFERENCES
RFC2 616 is available from the following URL:
Modification Type: | Minor | Last Reviewed: | 8/9/2004 |
---|
Keywords: | kbdownload kbdownload kbfile kbinfo KB294735 |
---|
|