Web Clients

24
1 Web Clients Web Protocols and Practice Chapter 2

description

Web Clients. Chapter 2. Web Protocols and Practice. WEB CLIENTS. Topics. Web Protocols and Practice. WEB CLIENTS. Web Client Definition. Web Protocols and Practice. WEB CLIENTS. Web Client Definition. Web Protocols and Practice. WEB CLIENTS. Browser Functions. - PowerPoint PPT Presentation

Transcript of Web Clients

Page 1: Web Clients

1

Web Clients

Web Protocols and Practice

Chapter 2

Page 2: Web Clients

2

Topics

Web Protocols and Practice

WEB CLIENTS

Web Client Definition Browser Functions Canonical Web Transfer Example Browser Caching Browser Configuration Cookies

Page 3: Web Clients

3

Web Client Definition

Web Protocols and Practice

WEB CLIENTS

Three major software components of the Web: Client

» A client is a program that sends Web requests and receives responses

Proxy Server

Page 4: Web Clients

4

Web Client Definition

Web Protocols and Practice

WEB CLIENTS

Three different Web clients: A browser

» A browser initiates a Web request

A spider» A spider is an example of a client program that is not directly

triggered by end users

» Spiders are necessary for fetching and indexing resources

An agent» An agent is a program that runs on behalf of users for specific

applications

Page 5: Web Clients

5

Browser Functions

Web Protocols and Practice

WEB CLIENTS

A browser primarily implements a Web client. A browser session is thus a series of requests

sent by the user, possibly based on the responses received at each stage.

The key advance in modern browsers is the ability to seamlessly navigate across links around the Internet.

Page 6: Web Clients

6

URL

Browser DNS server

Origin server

1 DNS query

2 TCP Connection

3 HTTP Request

4 HTTP Response

5 Optional parallel connections

Figure 2.1. Steps in a browser process

Web Protocols and Practice

WEB CLIENTS

Page 7: Web Clients

7

Figure 2.1 shows the various steps in the process involved in a Web request as processed by a typical browser. The selected URL is parsed to determine the Web server that must be contacted. A connection is set up with the server, and an HTTP request is sent with the URL to obtain the response.

Page 8: Web Clients

8

Table 2.1. User action leading to request generation

Input choiceRequest constructed from

Forward/Backward button

Selecting a link

Bookmarks

Click on Submit/Press Return

URL Window

Various menus

Images

Reload

Browser’s history mechanism

Corresponding URL string in HTML text

User’s collection of interesting links

URL corresponding to button/form

User input

Menu item selected

User click, automatically generated

request

Current URL

Web Protocols and Practice

WEB CLIENTS

Page 9: Web Clients

9

Canonical Web Transfer Example

Web Protocols and Practice

WEB CLIENTS

In the canonical example, we assume: A document consisting of a few embedded images

must be downloaded by a client form an origin server.

The client communicate directly with the origin server and does not go through an intermediary.

No caching of resources is involved

Figure 2.2 shows the result of requesting

http://www.bar.com/foo.html by a client in the canonical example condition mentioned above.

Page 10: Web Clients

10

Table 2.2. Resources referred to in the canonical example and their content type

Web Protocols and Practice

WEB CLIENTS

ResourceDescriptionContent type

/foo.html

/foo1.gif

/foo2.gif

/foo3.jpg

/book.cgi

/mp.tv

HTML container document

Embedded image

Embedded image

Embedded image

Executable script

Multimedia document

HTML

GIF

GIF

JPEG

CGI

Special format

Page 11: Web Clients

11

Foo1.gif Foo2.gif

Foo3.jpg

SUBMIT

Name:

Address:

:Credit Card

:Book Title

Mp.tv Book.cgi

Figure 2.2. Container document foo.html

Web Protocols and Practice

WEB CLIENTS

Page 12: Web Clients

12

Browser Caching

Web Protocols and Practice

WEB CLIENTS

There are two locations for browser caching: A portion of memory of the running process A portion of the file system’s disk space

Cache revalidation Checking the cached copy against the current

copy on the origin server to verify that the cached copy is still fresh or it is stale

Page 13: Web Clients

13

Browser Caching

Web Protocols and Practice

WEB CLIENTS

Cache consistency Ensuring that cached resources on the origin

server are still fresh» Strong

Revalidation the cached version against the origin server each time a request for the resource is made

» Weak Revalidation the cached version against the origin

server periodically At fixed interval Depending on resource attributes (size, last

time it was modified, content type, etc.)

Page 14: Web Clients

14

Issuing Request By Browser

Web Protocols and Practice

WEB CLIENTS

The HTTP request message is the unit of communication between client and server. It consists of header and optional request body:

» Header includesIdentification of user agent, acceptable encoding format and credential showing that user has access rights to resource

Page 15: Web Clients

15

Browser Configuration

Web Protocols and Practice

WEB CLIENTS

A browser can be customized by the user: Specifies how requests are routed

» Via a proxy» Some other intermediary» Sent directly to the origin server

Specifies how responses are received» Determining appearance» Stating Language

Page 16: Web Clients

16

Browser Configuration

Web Protocols and Practice

WEB CLIENTS

A browser may use several helper programs to handle response, and choice and handling of such helper applications are configurable.

Page 17: Web Clients

17

Table 2.3. Helper applications launched based on file/content types

Web Protocols and Practice

WEB CLIENTS

Content typeMIME typeHelper application

Zip compressed data

PostScript document

Word document

PDF document

audio/video

application/x-zip-compressed

application/postscript

application/msword

application/pdf

video/x-mpeg-2

gunzip/WINZIP32

ghostview/GSVIEW32

catdoc/WINWORD

acroread/ACRORD32

raplayer/MPLAYER2

Page 18: Web Clients

18

Foo.ra

Browser

Origin server

1 HTTP request for foo.ra

2( Location, protocol)

Figure 2.3. Listening to audio data

Web Protocols and Practice

Audio client Media server

3 Audio protocol request

WEB CLIENTS

Page 19: Web Clients

19

Figure 2.3: The user selects a resource http://www.bar.com/foo.ra, and the browser sends an HTTP request to the origin server www.bar.com for the resource foo.ca (step 1). The origin server sends back an HTTP response (step 2), but the content of the response is simply a pointer to the information. The response is meaningful only to an audio client rather than a Web browser. Typically, the response is a URL such as pnm://ra-ms.com/foo.ra, where pnm stands for "Progressive Network Media" and ra-ms is the media server on which the resource foo.ca resides. Because the browser has been configured to invoke the helper program based on the file type, it would invoke the real-audio client program, which would contact the media server ra-ms.com (step 3) and start downloading the audio content.

Page 20: Web Clients

20

Browser Configuration

Web Protocols and Practice

WEB CLIENTS

Plug-in A piece of code that is supplied to interpret certain

kinds of data within the context of a browser.» Shockwave: an example of a plug-in which is needed

by a browser to display a specific kind of animation.

The ability of a browser to speak other protocols enables it to be a uniform front end to a very

wide range of applications.

Page 21: Web Clients

21

Cookies

Web Protocols and Practice

WEB CLIENTS

Cookies are a way to manage state in HTTP. A cookie is a small amount of state that is sent

by the server at a web site to the browser and stored on the user's machine on behalf of the server.

"shopping cart".» what has already been put into the

shopping cart » what was purchased last time

Page 22: Web Clients

22

Cookies

Web Protocols and Practice

WEB CLIENTS

The next time the user visit the web site, browser will include the cookie information in a request header.

Cookies are often used as an index into a database maintained by the origin server to identify the user's state.

A cookie can be up to 4KB long. Individual browsers provide maximum 20 cookies

per server

Page 23: Web Clients

23

Figure 2.4. Client-server exchange of cookie information

Web Protocols and Practice

ClientOrigin

Server A

Request

WEB CLIENTS

ClientOrigin

Server A

Response

ClientOrigin

Server A

Request

Set-Cookie: XYZ

Cookie: XYZ

Page 24: Web Clients

24

Figure 2.4 shows a client sending a request to an origin server )step 1(. The origin server in its response includes the header )Set-cookie( with the cookie value )XYZ( )step 2(. In all future requests to the origin server A, the client includes the cookie )step3, sent with the request via the header cookie(.