Overview of Hypertext Transfer Protocol
Robert D. Cameron
January 28, 2004
HTTP/1.1
HTTP/1.1 is the current, stable version of Hypertext Transfer
Protocol as defined in
RFC
2616 of the Internet Engineering Task Force (June 1999).
I. Request/Response Client/Server Protocol
HTTP operates through the exchange of messages:
- HTTP Requests sent from clients to servers.
- HTTP Responses from servers to clients.
|
Client |
HTTP Request Message ->
<- HTTP Response Message |
Server |
Statelessness
HTTP is fundamentally a stateless protocol.
- There are no mandated server-side state changes through
a request/response interchange.
- Although a client may interact with a server through a
series of interchanges, each such interchange is considered
a complete and independent transaction from the HTTP perspective.
- Usually, there are no mandated client-side state
changes through an interchange.
However, cookies, redirections and actions of
scripts can require client-side actions.
Intermediaries: Proxies, Tunnels, Gateways
HTTP messages may go through a number of intermediaries.
Requests and responses may be modified along the way.
|
Client |
HTTP Request Message ->
<- (Modified) HTTP Response Message |
Proxy |
(Modified) HTTP Request Message ->
<- HTTP Response Message |
Tunnel |
HTTP Request Message ->
<- (Modified) HTTP Response Message |
Gateway |
(Modified) HTTP Request Message ->
<- HTTP Response Message |
Server |
- Proxy
-
- Acts as both HTTP client and server.
- Receives requests from clients and passes them on, possibly
translated.
- Accepts responses from servers and relays them back to
originating client.
- Possibly non-transparent: adding information, value
added service.
- Tunnel
-
- An intermediary that acts as a blind relay: no modification of
requests or responses.
- Gateway
-
- A server which acts as an intermediary for some other
server. Also known as a reverse proxy.
Connections
Under HTTP/1.0, a separate TCP connection was generally
established for each request/response interchange.
HTTP/1.1 permits and encourages continuous connections for a
series of request/response interchanges. This increases
communication efficiency.
Pipelining is also supported: clients may send multiple requests
without waiting for responses.
II. Requests
The basic structure of an HTTP request is composed of five
elements.
- A method (e.g., GET or POST).
- A requested URI (Uniform Resource Identifier) for
query/retrieval.
- The HTTP version (HTTP/1.1 typically).
- Headers that may control the request.
- A possible message body (e.g. for POST).
GET Requests
The GET request is the basic method to retrieve content
associated with a URI.
- A conditional GET may be issued to retrieve data only
under certain circumstances, using headers such as
If-Modified-Since, If-Match.
- A partial GET may be issued to retrieve part of a data
entity through the Range header.
HEAD Requests
The HEAD request is a partial GET that retrieves only the
response headers associated with request. No message body is to be
returned.
POST Requests
The POST request is the basic mechanism for uploading data to be
associated with a particular URI. It is often used with HTML forms
to send data from the client to the server.
PUT and DELETE Requests
HTTP also provides two lesser used requests related to
modification of web content. Most web services do not support these
methods.
- The PUT request provides new content to be associated with a
URI.
- The DELETE request asks that the content associated with a URI
be deleted.
Other Methods: OPTIONS, TRACE, CONNECT
The OPTIONS, TRACE and CONNECT methods support various control
mechanisms associated with the communication process.
These methods are not typically invoked by user actions.
III. Responses
The basic structure of an HTTP response is composed of four
elements.
- The HTTP version (HTTP/1.1 typically).
- A status code and description.
- Response headers.
- The message body of the response
Response Codes
Response codes are organized into five classes.
- 1xx: Informational codes (processing continues).
- 2xx: Success codes.
- 3xx: Redirection codes.
- 4xx: Client error codes (bad request syntax, etc.)
- 5xx: Server error codes.
Redirection
Redirection is a crucial feature of HTTP that requests the
client to automatically reissue a request to a different URI.
Time delays can be inserted with the Retry-After header.
Content-Type
Content-type is a key header that tells the client what type of
content the server is sending back.
- text/html - HTML content.
- application/octet-stream - binary file.