chapter 27 www and http - kasetsart universityplw/dccn/presentation/ch27.pdf · chapter 27 www and...

36
Chapter 27 WWW and HTTP 27.1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Upload: doduong

Post on 05-Mar-2018

247 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Chapter 27

WWW and HTTP

27.1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Page 2: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

2727--1 ARCHITECTURE1 ARCHITECTURE

TheThe WWWWWW todaytoday isis aa distributeddistributed client/serverclient/server service,service,inin whichwhich aa clientclient usingusing aa browserbrowser cancan accessaccess aa serviceserviceusingusing aa serverserver.. However,However, thethe serviceservice providedprovided isisdistributeddistributed overover manymany locationslocations calledcalled sitessites..

Topics discussed in this section:Topics discussed in this section:Client (Browser)Server

Topics discussed in this section:Topics discussed in this section:

ServerUniform Resource LocatorCookies

27.2

Page 3: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.1 Architecture of WWW

27.3

Page 4: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.2 Browser

27.4

Page 5: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.3 URL

27.5

Page 6: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

2727--2 2 WEB DOCUMENTSWEB DOCUMENTS

ThTh d td t ii thth WWWWWW bb dd i ti t ththTheThe documentsdocuments inin thethe WWWWWW cancan bebe groupedgrouped intointo threethreebroadbroad categoriescategories:: staticstatic,, dynamicdynamic,, andand activeactive.. TheThe

tt ii b db d thth titi tt hi hhi h thth t tt t ffcategorycategory isis basedbased onon thethe timetime atat whichwhich thethe contentscontents ofofthethe documentdocument areare determineddetermined..

Static DocumentsTopics discussed in this section:Topics discussed in this section:

Dynamic DocumentsActive Documents

27.6

Page 7: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.4 Static document

27.7

Page 8: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.5 Boldface tags

27.8

Page 9: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.6 Effect of boldface tags

27.9

Page 10: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.7 Beginning and ending tags

27.10

Page 11: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.8 Dynamic document using CGI

27.11

Page 12: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.9 Dynamic document using server-site script

27.12

Page 13: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Note

Dynamic documents are sometimes f d t it d ireferred to as server-site dynamic

documents.

27.13

Page 14: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.10 Active document using Java applet

27.14

Page 15: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.11 Active document using client-site script

27.15

Page 16: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Note

Active documents are sometimes f d t li t it d ireferred to as client-site dynamic

documents.

27.16

Page 17: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

2727--3 3 HTTPHTTP

TheThe HypertextHypertext TransferTransfer ProtocolProtocol (HTTP)(HTTP) isis aa protocolprotocolTheThe HypertextHypertext TransferTransfer ProtocolProtocol (HTTP)(HTTP) isis aa protocolprotocolusedused mainlymainly toto accessaccess datadata onon thethe WorldWorld WideWide WebWeb..HTTPHTTP functionsfunctions asas aa combinationcombination ofof FTPFTP andand SMTPSMTPHTTPHTTP functionsfunctions asas aa combinationcombination ofof FTPFTP andand SMTPSMTP..

HTTP TransactionTopics discussed in this section:Topics discussed in this section:

Persistent Versus Nonpersistent Connection

27.17

Page 18: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Note

HTTP uses the services of TCP on well-k t 80known port 80.

27.18

Page 19: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.12 HTTP transaction

27.19

Page 20: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.13 Request and response messages

27.20

Page 21: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.14 Request and status lines

27.21

Page 22: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Table 27.1 Methods

27.22

Page 23: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Table 27.2 Status codes

27.23

Page 24: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Table 27.2 Status codes (continued)

27.24

Page 25: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.15 Header format

27.25

Page 26: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Table 27.3 General headers

27.26

Page 27: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Table 27.4 Request headers

27.27

Page 28: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Table 27.5 Response headersb e 7.5 espo se eade s

27.28

Page 29: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Table 27.6 Entity headers

27.29

Page 30: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Example 27.1

This example retrieves a document. We use the GETmethod to retrieve an image with the path /usr/bin/image1.The request line shows the method (GET), the URL, andh i ( ) h h d h li hthe HTTP version (1.1). The header has two lines that

show that the client can accept images in the GIF orG f h d h b d hJPEG format. The request does not have a body. The

response message contains the status line and four linesf h d Th h d li d fi h d MIMEof header. The header lines define the date, server, MIME

version, and length of the document. The body of thed f ll h h d ( Fi 27 16)document follows the header (see Figure 27.16).

27.30

Page 31: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.16 Example 27.1

27.31

Page 32: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Example 27.2

In this example, the client wants to send data to theserver. We use the POST method. The request line showsthe method (POST), URL, and HTTP version (1.1). There

f li f h d h b d i hare four lines of headers. The request body contains theinput information. The response message contains the

li d f li f h d h dstatus line and four lines of headers. The createddocument, which is a CGI document, is included as theb d ( Fi 27 17)body (see Figure 27.17).

27.32

Page 33: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Figure 27.17 Example 27.2

27.33

Page 34: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Example 27.3

HTTP uses ASCII characters. A client can directlyconnect to a server using TELNET, which logs into port80 (see next slide). The next three lines show that the

i i f l h h li hconnection is successful. We then type three lines. Thefirst shows the request line (GET method), the second ish h d (d fi i h h ) h hi d i bl kthe header (defining the host), the third is a blank,

terminating the request. The server response is sevenli i i h h li Th bl k li hlines starting with the status line. The blank line at theend terminates the server response. The file of 14,230li i i d f h bl k li ( h h )lines is received after the blank line (not shown here).The last line is the output by the client.

27.34

Page 35: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Example 27.3 (continued)

27.35

Page 36: Chapter 27 WWW and HTTP - Kasetsart Universityplw/dccn/presentation/ch27.pdf · Chapter 27 WWW and HTTP ... 27.24. Figure 27.15 Header format 27.25. ... Microsoft PowerPoint - ch27.ppt

Note

HTTP version 1.1 specifies a persistent ti b d f ltconnection by default.

27.36