HTTP Message
HTTP Message
Application Layer
www.someschool.edu/someDept/pic.gif
2: Application Layer 2
HTTP overview
HTTP: hypertext
transfer protocol HT
TP
req
Web’s application layer PC running HT ues
TP t
protocol Explorer re sp
ons
client/server model e
2: Application Layer 3
HTTP overview (continued)
Uses TCP: HTTP is “stateless”
client initiates TCP server maintains no
connection (creates socket) information about
to server, port 80 past client requests
server accepts TCP
connection from client aside
Protocols that maintain
HTTP messages (application- “state” are complex!
layer protocol messages) past history (state) must
exchanged between browser be maintained
(HTTP client) and Web if server/client crashes,
server (HTTP server)
their views of “state” may
TCP connection closed
be inconsistent, must be
reconciled
2: Application Layer 4
HTTP connections
Nonpersistent HTTP Persistent HTTP
At most one object is Multiple objects can
sent over a TCP be sent over single
connection. TCP connection
HTTP/1.0 uses between client and
nonpersistent HTTP server.
HTTP/1.1 uses
persistent connections
in default mode
2: Application Layer 5
Nonpersistent HTTP
(contains text,
Suppose user enters URL www.someSchool.edu/someDepartment/home.index
references to 10
jpeg images)
time
2: Application Layer 6
Nonpersistent HTTP (cont.)
2: Application Layer 7
Non-Persistent HTTP: Response time
Definition of RTT: time to
send a small packet to
travel from client to
server and back. initiate TCP
Response time: connection
RTT
one RTT to initiate TCP
request
connection file
time to
one RTT for HTTP request RTT
transmit
and first few bytes of file
file
HTTP response to return received
file transmission time
time
total = 2RTT+transmit time time
2: Application Layer 8
Persistent HTTP
2: Application Layer 9
HTTP request message
two types of HTTP messages: request, response
HTTP request message:
ASCII (human-readable format)
request line
(GET, POST, GET /somedir/page.html HTTP/1.1
HEAD commands) Host: www.someschool.edu
User-agent: Mozilla/4.0
header Connection: close
lines Accept-language:fr
Carriage return,
line feed (extra carriage return, line feed)
indicates end
of message
2: Application Layer 10
HTTP request message: general format
2: Application Layer 11
Uploading form input
Post method:
Web page often
includes form input URL method:
Input is uploaded to Uses GET method
server in entity body Input is uploaded in
URL field of request
line:
www.somesite.com/animalsearch?monkeys&banana
2: Application Layer 12
Method types
HTTP/1.0 HTTP/1.1
GET GET, POST, HEAD
POST PUT
HEAD uploads file in entity
body to path specified
asks server to leave
in URL field
requested object out of
response DELETE
deletes file specified in
the URL field
2: Application Layer 13
Method Types
The first line of an HTTP request message is called the
request line; the subsequent lines are called the header
lines. The request line has three fields: the method field,
the URL field, and the HTTP version field.
The method field can take on several different values,
including GET, POST, HEAD, PUT, and DELETE.
The great majority of HTTP request messages use the
GET method. The GET method is used when the browser
requests an object, with the requested object identified in
the URL field.
2: Application Layer 14
GET vs POST Method
The entity body is empty with the GET method, but is used
with the POST method.
An HTTP client often uses the POST method when the
user fills out a form—for example, when a user provides
search words to a search engine.
With a POST message, the user is still requesting a Web
page from the server, but the specific contents of the Web
page depend on what the user entered into the form fields.
If the value of the method field is POST, then the entity
body contains what the user entered into the form fields.
2: Application Layer 15
HEAD, PUT, and DELETE
The HEAD method is similar to the GET method. When a
server receives a request with the HEAD method, it
responds with an HTTP message but it leaves out the
requested object. Application developers often use the
HEAD method for debugging.
The PUT method is often used in conjunction with Web
publishing tools. It allows a user to upload an object to a
specific path (directory) on a specific Web server.
The PUT method is also used by applications that need to
upload objects to Web servers.
The DELETE method allows a user, or an application, to
delete an object on a Web server.
2: Application Layer 16
HTTP response message
status line
(protocol
status code HTTP/1.1 200 OK
status phrase) Connection close
Date: Thu, 06 Aug 1998 12:00:15 GMT
header Server: Apache/1.3.0 (Unix)
lines Last-Modified: Mon, 22 Jun 1998 …...
Content-Length: 6821
Content-Type: text/html
2: Application Layer 17
HTTP response status codes
In first line in server->client response message.
A few sample codes:
200 OK
request succeeded, requested object later in this message
301 Moved Permanently
requested object moved, new location specified later in
this message (Location:)
400 Bad Request
request message not understood by server
404 Not Found
requested document not found on this server
505 HTTP Version Not Supported
2: Application Layer 18
Thank You
2: Application Layer 19