200 likes | 305 Views
Chapter 22. World Wide Web: HTTP. Objectives . Upon completion you will be able to:. Know how HTTP accesses data on the WWW. 22.3 HTTP.
E N D
Chapter 22 World Wide Web:HTTP Objectives Upon completion you will be able to: • Know how HTTP accesses data on the WWW TCP/IP Protocol Suite
22.3 HTTP The Hypertext Transfer Protocol (HTTP) is a protocol used mainly to access data on the World Wide Web. HTTP functions like a combination of FTP and SMTP. The topics discussed in this section include: HTTP Transaction Persistent versus Nonpersistent Connection Proxy Server TCP/IP Protocol Suite
Figure 22.12HTTP transaction HTTP uses the services of TCP on the well-known port number 80. TCP/IP Protocol Suite
Figure 22.13Request and response messages A request message consists of a request line, a header, and sometimes a body. A response message consists of a status line, a header, and sometimes a body. TCP/IP Protocol Suite
Figure 22.14Request and status lines Request type: a particular method (methods are shown on the next slide) HTTP version: 1.1 Status code: similar to those in SMTP (see slides 7 and 8) Status phrase: the text version of the status code (also shown in slides 7 and 8) TCP/IP Protocol Suite
Table 22.1 Methods TCP/IP Protocol Suite
Table 22.2 Status codes TCP/IP Protocol Suite
Table 22.2 Status codes (continued) TCP/IP Protocol Suite
Figure 22.15Header format The header exchanges additional info between the client and the server. The header can consist of one or more header lines. Each header line looks like this: There are four categories of header lines: general header, request header, response header, and entity header. TCP/IP Protocol Suite
Table 22.3 General headers Gives general information about the message and can be present in both a request and a response. TCP/IP Protocol Suite
Table 22.4 Request headers Only present in a request message; specifies the client’s configuration and preferred document format. TCP/IP Protocol Suite
Table 22.5 Response headers TCP/IP Protocol Suite
Table 22.6 Entity headers Gives info about the body of the document; mostly present in response messages, but also present in some request messages such as POST or PUT methods that contain a body. TCP/IP Protocol Suite
Example 1 This example retrieves a document. We use the GET method to retrieve an image with the path /usr/bin/image1. The request line shows the method (GET), the URL, and the HTTP version (1.1). The header has two lines that show that the client can accept images in the GIF or JPEG format. The request does not have a body. The response message contains the status lineand four lines of header. The header lines define the date, server, MIME version, and length of the document. The body of the document follows the header (see Figure 22.16). See Next Slide TCP/IP Protocol Suite
Figure 22.16Example 1 TCP/IP Protocol Suite
Example 2 In this example, the client wants to send data to the server. We use the POST method. The request line shows the method (POST), URL, and HTTP version (1.1). There are four lines of headers. The request body contains the input information. The response message contains the status line and four lines of headers. The created document, which is a CGI document, is included as the body (see Figure 22.17). See Next Slide TCP/IP Protocol Suite
Figure 22.17Example 2 TCP/IP Protocol Suite
Example 3 Here is the first request in a notification server session: POST http://gateway.messenger.hotmail.com/gateway/gateway.dll?Action=open&Server= NS&IP=messenger.hotmail.com HTTP/1.1Accept: */*Accept-Language: en-usAccept-Encoding: gzip, deflateUser-Agent: MSMSGS Host: gateway.messenger.hotmail.comProxy-Connection: Keep-AliveConnection: Keep-AlivePragma: no-cacheContent-Type: application/x-msn-messengerContent-Length: 18 VER 5 MSNP8 CVR0 TCP/IP Protocol Suite
Example 3 Here is the response: HTTP/1.0 200 OKServer: Microsoft-IIS/5.0Date: Tue, 18 Mar 2003 07:39:53 GMTX-MSN-Messenger: SessionID=954547325.13160; GW-IP=207.46.110.18Content-Length: 18Content-Type: application/x-msn-messengerAge: 0Via: HTTP/1.1 ntl_site (Traffic-Server/5.2.0-R [c sSf ])X-Cache: MISS from nautilus.localdomainX-Cache-Lookup: MISS from nautilus.localdomain:80Proxy-Connection: keep-alive VER 5 MSNP8 CVR0 TCP/IP Protocol Suite
HTTP version 1.1 specifies a persistent connection by default. In other words, the server leaves the connection open for more requests after sending a response. HTTP v1 opened a separate TCP connection for each part (image) of the web page. Very wasteful. TCP/IP Protocol Suite