HTTP
As we just have seen, the process of interaction between browsers
and servers seems to be of trivial nature: a connection has to be
established, the browser sends a request to the server, the server
sends a response afterwards the connection is closed. However, in order
to avoid any kind of "misunderstanding" the requests and responses
must have an exactly defined structure. In this section we are going
to examine how the requests and responses of a browser-server
interaction are built up.
Like any other communication between different programs the
communication between a browser and a server is regulated by a
protocol which in this case is called HyperText Transfer Protocol
(HTTP).
HTTP lays down the following syntactical structure for a clients
request:
<method><URL>[<version>][<headers>][<data>]
The items in brackets are optional, i.e. they are not necessarily part
of a HTTP request. <method> describes how the server
should
be accessed. Typical examples are:
- GET : To fetch a document
- HAED : To get information out of a html-document's
head
- POST : To hand over data to the server
<version> is normally set to HTTP/1.0 and some
common <headers>
are:
- From : Contains the e-mail address of the user who is
running the client
- Accept : Contains a list of MIME-types which the client
can display (e.g. text/plain, text/html,
... )
- ChargeTo : Contains account details of the user
- ...
Here is an example for a HTTP request:
GET /path/file.html HTTP/1.0
Accept : text/plain, text/html, image/jpeg
A HTTP response is syntactically structured as follows:
<version><code><reason>[<headers>][<data>]
Again the items in brackets are optional. But every HTTP response
contains informations about the <version> which
generally is set
to HTTP/1.0 and information about the requested
document.
<code><reason> denote status codes which either indicate
that the
request was processed correctly or that an error occurred. The
different status codes are:
- 200-299 : Specify a successful response (e.g.
200 ok )
- 300-399 : Indicate redirection (e.g. 301 moved )
- 400-499 : Specify a client error (e.g.
402 payment required )
- 500-599 : Specify a server error (e.g.
502 service temporarily overloaded )
Examples for common <headers> are:
- Server : Contains the name of the server
- Allowed : Numbers the methods to access the server (e.g.
GET, HEAD, POST )
- Content-type : contains the MIME-type of the requested
document
- Content-length : Contains the document's length
- ...
Finally, <data> contains the requested document itself.
Thus, a HTTP response may be given as:
HTTP/1.0 200 Document follows
Date: Wed,21 Aug 1996 14:53:30 GMT
Server: NSCA/1.4.1
Content-type: text/html
Last-modified: Tue, 20 Aug 1996 29:26:42 GMT
Content-length: 3675
...
back to
the previous section
or continue with
some related links