2. Index
Introduction
Message format
Methods
Status codes
Headers
General headers
Request headers
Response headers
Entity headers
Entities
Chunked transfer
4. The Hypertext Transfer Protocol (HTTP) began as an
extremely basic protocol.
It was designed to do just one thing: allow a client
to send a simple request for a hypertext file and
receive it back from the server.
5. Modern HTTP remains at its heart a straight-forward
request/reply protocol, but now includes many
new features and capabilities to support the
growing size of the World Wide Web.
6. Basic communication consists of a request
message sent by a client to a server, which returns
a response back to the client.
7. Since HTTP/1.1 we have persistent connections.
Multiple requests to the same server use the same
TCP connection.
12. start line
general headers
GET /index.html HTTP/1.1
Date: Wed, 23 Jun 2010 13:27:42 CET
Connection: close
Host: www.somesite.com
From: me@anothersite.com
Accept: text/html, text/plain
User-Agent: Mozilla/4.0 (Windows 98; U)
(empty body)
request headers
13. General headers refer to the message itself and are
used to control the processing or provide extra info.
Request headers convey more details about the
request and provide info about how the request is
handled.
Entity headers describe the entity contained in the
message body.
15. start line
general headers
HTTP/1.1 200 OK
Date: Wed, 23 Jun 2010 13:27:43 CET
Connection: close
Server: Apache/1.3.27
Accept-Ranges: bytes
Content-Type: text/html
Content-Length: 170
Last-Modified: Mon, 17 May 2004 12:11:11
entity
<html><head><title>Test</title></head> headers
<body><p>test</p></body></html>
response headers body
17. All client/server protocols provide a way for the
client to prompt the server to take action,
generally by having the client give the server a
series of commands.
18. HTTP does not have commands but rather a fixed
set of methods that can be applied to any
thinkable resource.
20. PUT is placing or replacing a resource at a given
location.
PUT is idempotent: it has no side effects. You may
repeat it and the result is the same.
21. POST is merely sending data to a resource
location. It can be handled by the server in
anyway it wants. It may store the data privately. It
may store it at the current location. It may update
many resources. It may self destruct.
23. Each HTTP response includes both a numeric status
code and a text reason phrase, both of which
indicate the disposition of the corresponding client
request.
26. The limited amount of methods may give the
impression that HTTP is quite limited. But much of
the functionality is implemented by the message
headers.
41. Entity headers describe the nature of the entity in
the message body, including its type, language
and encoding, to facilitate the proper processing
and/or presentation of the entity by the device
receiving it.
45. While HTTP is naturally associated with hypertext, its
messages can transport a large variety of different
types of files, including images, audio, video and
much more.
46. To indicate the type of entity contained in an HTTP
message, its sender must identify its media type
and subtype. This is done using the HTTP Content-
Type header, which was borrowed from the
Multipurpose Internet Mail Extensions (MIME)
specification.
47. Even though HTTP borrows several concepts and
header types from MIME, the protocol is not MIME-
compliant.
48. Content encoding tells something about the
encoding of the entity.
Transfer-encoding tells something about the entire
HTTP message, and may change from hop to hop.
50. Since HTTP/1.1 uses persistent connections that
allow multiple requests and responses to be sent
over a TCP connection, clients and servers need
some way to identify where one message ends
and the next begins.
51. The easiest way is to send the Content-Length
header with the message size. But for dynamic
content you may not know this in advance. In this
case you can use chunked transfer encoding.
53. HTTP/1.1 200 OK
Date: Mon, 22 Mar 2004 11:15:03 GMT
Content-Type: text/html
Content-Length: 129
Expires: Sat, 27 Mar 2004 21:12:00 GMT
<html><body><p>The file you requested is 3,400 bytes long
and was last modified: Sat, 20 Mar 2004 21:12:00
GMT.</p></body></html>
54. HTTP/1.1 200 OK
Date: Mon, 22 Mar 2004 11:15:03 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Trailer: Expires
29
<html><body><p>The file you requested is
5
3,400
23
bytes long and was last modified:
1d
Sat, 20 Mar 2004 21:12:00 GMT
13
.</p></body></html>
0
Expires: Sat, 27 Mar 2004 21:12:00 GMT