Title: Web Clients
1 Web Clients
Chapter 2
Web Protocols and Practice
2Topics
WEB CLIENTS
Web Client Definition Browser Functions Canonical Web Transfer Example Browser Caching Browser Configuration Cookies
Web Protocols and Practice
3Web Client Definition
WEB CLIENTS
Three major software components of the Web Client A client is a program that sends Web requests and receives responses Proxy Server
Web Protocols and Practice
4Web Client Definition
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
Web Protocols and Practice
5Browser Functions
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.
Web Protocols and Practice
6Browser
DNS server
WEB CLIENTS
1 DNS query
URL
Origin server
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
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.
8Table 2.1. User action leading to request
generation
WEB CLIENTS
Request constructed from Input choice
Browsers history mechanism Corresponding URL string in HTML text Users collection of interesting links URL corresponding to button/form User input Menu item selected User click, automatically generated request Current URL Forward/Backward button Selecting a link Bookmarks Click on Submit/Press Return URL Window Various menus Images Reload
Web Protocols and Practice
9Canonical Web Transfer Example
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.
Web Protocols and Practice
10Table 2.2. Resources referred to in the canonical
example and their content type
WEB CLIENTS
Content type Description Resource
HTML GIF GIF JPEG CGI Special format HTML container document Embedded image Embedded image Embedded image Executable script Multimedia document /foo.html /foo1.gif /foo2.gif /foo3.jpg /book.cgi /mp.tv
Web Protocols and Practice
11WEB CLIENTS
Foo1.gif
Foo2.gif
Foo3.jpg
Name Address Credit Card Book Title
SUBMIT
Mp.tv
Book.cgi
Figure 2.2. Container document foo.html
Web Protocols and Practice
12Browser Caching
WEB CLIENTS
There are two locations for browser caching A portion of memory of the running process A portion of the file systems 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
Web Protocols and Practice
13Browser Caching
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.)
Web Protocols and Practice
14Issuing Request By Browser
WEB CLIENTS
The HTTP request message is the unit of communication between client and server. It consists of header and optional request body Header includes Identification of user agent, acceptable encoding format and credential showing that user has access rights to resource
Web Protocols and Practice
15Browser Configuration
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
Web Protocols and Practice
16Browser Configuration
WEB CLIENTS
A browser may use several helper programs to handle response, and choice and handling of such helper applications are configurable.
Web Protocols and Practice
17Table 2.3. Helper applications launched based on
file/content types
WEB CLIENTS
Helper application MIME type Content type
gunzip/WINZIP32 ghostview/GSVIEW32 catdoc/WINWORD acroread/ACRORD32 raplayer/MPLAYER2 application/x-zip-compressed application/postscript application/msword application/pdf video/x-mpeg-2 Zip compressed data PostScript document Word document PDF document audio/video
Web Protocols and Practice
18Browser
WEB CLIENTS
Foo.ra
Origin server
1 HTTP request for foo.ra
2 (Location, protocol)
3 Audio protocol request
Media server
Audio client
Figure 2.3. Listening to audio data
Web Protocols and Practice
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.
20Browser Configuration
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.
Web Protocols and Practice
21Cookies
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
Web Protocols and Practice
22Cookies
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
Web Protocols and Practice
23WEB CLIENTS
Origin Server A
Client
Request
Client
Origin Server A
Response
Set-Cookie XYZ
Origin Server A
Request
Client
Cookie XYZ
Figure 2.4. Client-server exchange of cookie
information
Web Protocols and Practice
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).