Application Layer

2.2 The Web and HTTP

Home
Introduction
2.1 Principles of Network Applications
2.1.1 Network Application Architectures
2.1.2 Processes Communcating
2.1.3 Application-Layer Protocols
2.1.4 What Services Does an Application Need?
2.1.5 Services Provided by the Internet Transport Protocols
2.2 The Web and HTTP
2.2.1Overview of HTTP
2.2.2 Nonpersistent and Persistent Connections
2.2.3 HTTP Message Format
2.2.4 User-Server Ineraction: Cookies
2.2.5 HTTP Content
2.2.6 Web Caching
2.2.7 The Conditional GET
2.3 File Transfer: FTP
2.3.1 FTP Commands and Replies
2.4 Electronic Mail in the Internet
2.4.1 STMP
2.4.2 Comparison with HTTP
2.4.3 Mail Message Formats and MIME
2.4.4 Mail Access Protocols
2.5 DNS--The Internet's Directory Service
2.5.1 Services Provided by DNS
2.5.2 Overview of How DNS Works
2.5.3 DNS Records and Messages
2.6 P2P File Sharing
2.7 Socket Programming with TCP
2.7.1 Socket Programming with TCP
2.7.2 An Example Client/Server Application in Java
2.8 Socket Programming with UDP

2.2.3 HTTP Message Format

The HTTP specifications include the definitions of the HTTP message formats.  There are two types of HTTP messages, request messages and response messages.
 
HTTP Request Message
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 fields, and the HTTP version field.  The method field can take on several differenet values, including GET, POST, and HEAD.  The great majority of HTTP request messages use the GET method.  The GET method is used when the browser requests an object, whit the requested object identified in the URL field.
 
An HTTP client often uses the POST method when the user fills out a form.  With a POST message, the user is still requesting a Web page from the server, but  the specific contents of the Web page depends 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.
 
A request generated with a form does not necessarily use the POST method.  Instead, HTML forms often use the GET method and include the inputted data in the requested URL.  If a form uses the GET method, has two fields.
 
The HEAD method is similar to the GET method.  When a server receives a request withthe HEAD method, it responds with an HTTP message but it leaves oththe requested object. 

kurose_320719_c02f08.gif

HTTP Response Message
Response message has three sections: an initial status line, six header lines, and then the entity body.  The entity body is the meat of the message--it conatins the requested object itself.  The status line has three fields: the protocol version field, a status code, and a corresponding status message.
 
The werver uses the Connection: close header line to tell the client header line to tell the client that it is going to close the TCP connection after sending the message.  The Date: header line indicates the time and date when the HTTP response was created and sent by the server.  Note that this is not the time when the object was created or modified; it is the time when the server retrieves the object from its file system, inserts the object into the response message, and sends the response message.  The Server: header line indicates that the message was generated by Apache Web server; it is analogous to the User-agent: header line in the HTTP request message.  The Last-Modified (also known as proxy servers): header lline indicated the time and date when the object was created or last modifieed. The Content-Length: header line indicates teh number of bytes in the object being sent.  The Content-Type: header indicates that the object in the entity body is HTML text.

kurose_320719_c02f09.gif