Share via


HTTP Protocol Basics

Applies To: Windows Server 2003, Windows Server 2003 with SP1

Troubleshooting IIS often requires that you examine the communications between a Web client and the server running IIS. By understanding the fundamentals of this communication, you can easily interpret network monitor traces and similar records.

Hypertext Transfer Protocol (HTTP) is the communication protocol used to exchange information between a client system and a Web server across a TCP/IP connection. The interchange is generally referred to as an HTTP transaction. In an HTTP transaction, the client system opens a TCP connection with the Web server and submits an HTTP request. The Web server, in turn, issues an HTTP response, completing one HTTP transaction. HTTP is stateless, in that there is no provision in the protocols design for information about any single request persisting beyond one transaction.

The following code segment is an example of an HTTP GET request:

GET /default.htm HTTP/1.1\r\n
Host: rhynoruv\r\n
Accept: */*\r\n
\r\n

The request line contains an HTTP method, a Uniform Resource Identifier (URI), and the HTTP version number, followed by carriage return and line feed characters. Typically, the request line is followed by a series of HTTP headers. Depending on the type of request, an HTTP request can have a variety of headers. With HTTP 1.1, the simplest GET request consists of the request line and only one HTTP header — the Host header. Two carriage returns/line feeds designate the end of the HTTP request header. In a simple GET request, these indicate the end of the request. Some requests include data, which is called the entity body, in addition to the HTTP headers. In the HTTP request, the division between the headers and the entity body is designated by two carriage returns/line feeds.

The following code sample shows an HTTP response, which is similar to a request:

HTTP/1.1 200 OK\r\n
Content-Length: 50\r\n
Content-Type: text/html\r\n
Last-Modified: Sun, 20 Oct 2002 22:52:16 GMT\r\n
Accept-Ranges: bytes\r\n
ETag: "255591568b78c21:5cd"\r\n
Server: Microsoft-IIS/6.0\r\n
MicrosoftOfficeWebServer: 5.0_Pub\r\n
X-Powered-By: ASP.NET\r\n
Date: Sun, 20 Oct 2002 22:52:35 GMT\r\n
\r\n

<HTML>\r\n
<BODY>\r\n
\r\n
Hello World.\r\n
\r\n
</BODY>\r\n
</HTML>

The first line is the status line, which consists of the HTTP version, a numeric HTTP status code, and then a reason phrase that briefly explains the status code. The status code is often the first indicator of a problem. For information about status codes, see HTTP Status Codes in IIS 6.0.

There are two other important aspects of the HTTP protocol that you must understand before you attempt troubleshooting: the provisions for managing TCP connections and how credential management (authentication) occurs.