Figure 1-2. A web browser makes a request and the web server responds with the resource
An HTTP request is a textual description of a resource and additional
header information. Consider the following example request:
GET /index.html HTTP/1.0
From: hugh@computer.org (Hugh Williams)
User-agent: Hugh-fake-browser/version-1.0
Accept: text/plain, text/html
This example uses a GET method to request an HTML
page index.html with HTTP/1.0. In this example,
three additional header lines identify the user and the web browser
and define what data types can be accepted by the browser. A request
is normally made by a web browser and may include other headers; the
previous example was created manually by typing the request into
Telnet software.
An HTTP response has a response code and message, additional headers,
and usually the resource that has been requested. An example response
to the request for index.html is as follows:
HTTP/1.0 200 OK
Date: Sat, 21 Jul 2002 03:44:25 GMT
Server: Apache/1.3.20
Content-type: text/html
Content-length: 88
Last-modified: Fri, 1 Feb 2002 03:40:03 GMT
<html><head>
<title>Test Page</title></head>
<body>
<h1>It Worked!</h1>
</body></html>
The first line of the response agrees to use HTTP/1.0 and confirms
that the request succeeded by reporting the response code
200 and the message OK; another
common response is 404 Not
Found. In this example, five lines of additional
headers identify the current date and time, the web server software,
the data type, the length of the response, and when the resource was
last modified. After a blank line, the resource itself follows. In
this example the resource is the requested HTML document,
index.html.