The manual Page
Version française
     Working of HTTP  
[ index | glossary | news | downloads | links ]
 
  HTTP
working
HTTP/0.9
HTTP/1.0
HTTP/1.1
HTTP/1.0 status
HTTP/1.1 status
HTTP/1.1 directives
 
news
glossary
downloads
 
guest book
credits
contact
 
 
research
 
last update
11/09/2001
Valid HTML 4.0!
Valid CSS!
Hit-Parade
Measure your audience

How does it work?

The basic principle is a client/server connection: a client (the web browser) connects to a server, sends a request and the server replies. The connection is a simple TCP/IP socket connection, generally on port 80, but we use 8080 from time to time (usually with web proxys).

HTTP is a (very) simple protocol. It is so simple that we, human, can directly speak with web servers. We just need to open a connection on a web server with a telnet client and to type HTTP commands by hand. Here is a short example (what we must type is written in bold characters; [CR] means that we must strike the return key to add a line break):

$ telnet www.themanualpage.org 80[CR]
Trying...
Connected to web.pro.proxad.net.
Escape character is '^]'.
GET /http/hello.txt[CR]
Hello

Connection closed by foreign host.

By typing GET /http/hello.txt we ask for the /http/hello.txt document to the server called www.themanualpage.org, and the server returned the content of this file. It is the very basement of HTTP: we make a request with simple words and the server replies immediately with simple words as well and sends the result of the request.

Internet Explorer, Netscape and other web browsers, want you ask for a web page using a URL, do exactly the same (but you do not see it).

The different HTTP versions

The latest HTTP version is HTTP/1.1. Before this version, there were 2 other versions: HTTP/0.9 and HTTP/1.0. At the moment HTTP/1.0 is maybe the most commonly used version of the protocol. When we give the version of HTTP, we use HTTP/ followed by the number of the version.

When we connect to a server, one must first tell it which version we use. By default, is nothing is specified, we use HTTP/0.9. That is what happened in the example above. When we ask for a version the server does not implement, it sends first the version of HTTP it is going to use in its reply. The client should then be able to understand this version. Example:

$ telnet www.themanualpage.org 80
Trying...
Connected to web.pro.proxad.net.
Escape character is '^]'.
HEAD /http/hello.txt HTTP/1.0[CR]
[CR]
HTTP/1.1 200 OK
Date: Thu, 14 Oct 1999 06:43:02 GMT
Server: Apache/1.3.6 LV/LM-1.3 (Unix) PHP/3.0.9
Last-Modified: Sat, 08 Feb 1997 15:55:03 GMT
ETag: "afc0-8-32fca1d7"
Accept-Ranges: bytes
Content-Length: 8
Connection: close
Content-Type: text/plain

Connection closed by foreign host.

We can notice that this time the reply is much more complicated than before, it contains more data than before. To send this extra data, the client as well the server use what we call directives. For instance, "Content-Type" is a directive that specifies the type of the returned resource.

Making a request

A request is what we ask the server. In the first example, it was a GET request used to get (!!) a document. In the second example, we made a HEAD request in order to get only the header part of a complete reply we should get with a GET request (we will see later what this HEAD request is used for).

the different requests

HTTP request are performed by what we call methods. Here is the list of all available methods, and the version number with which they appeared:

request HTTP version description
GET HTTP/0.9 to get a document
HEAD HTTP/1.0 to get the header part of a complete reply
POST HTTP/1.0 to send data to the server
PUT HTTP/1.1 to ask the server to save the resource we are sending
DELETE HTTP/1.1 to delete a file on the server
TRACE HTTP/1.1 used to check what request the server has recieved
CONNECT HTTP/1.1 word reserved for proxys to create tunnels
OPTIONS HTTP/1.1 list of options available for a given resource

Formatting a request

Requests have a specific format only since HTTP/1.0.

For HTTP/0.9, the only possible request is the one seen in the first example:

$ telnet www.themanualpage.org 80[CR]
Trying...
Connected to web.pro.proxad.net.
Escape character is '^]'.
GET /http/hello.txt[CR]
[CR]

For HTTP/1.0 and later, requests are composed by 2 different parts: the header and the body of the request. The header is used to complete the request with directives (to say who is asking for the resource, what kind of web browser you are using...). Strictly speaking, headers are indispensable but as there is no header in HTTP/0.9, it is not that much mandatory. Conversely, we rarely put a body in a request; we only use one when using the POST or PUT methods, that is to say when the web browser wants to send data.

To learn more about this, see the HTTP/1.0 headers.

Server's replies

In HTTP/0.9, the reply is really simple, since the server directly sends the answer (HTML page, image...).

On the contrary, since HTTP/1.0, the server's reply is splitted in 2 parts: the header of the response and the body of the entity (the entity is the real result of the request). Headers contain information about the entity, once again defined by directives. For instance, the server says if the request was perfectly understood and treated, specifies the format of the sent resource... The entity's body is actually the requested document (say, the result of the request).

To read more about this, see server's replies in HTTP/1.0.

printable format printable format



Copyright © 2000-2001 themanualpage.org - This site is submissive to the terms of the GNU GPL and FDL licences.