0% found this document useful (0 votes)
11 views38 pages

WWW HTTP

The document provides an overview of the World Wide Web (WWW) and the HyperText Transfer Protocol (HTTP), detailing their architecture, functionality, and the differences between non-persistent and persistent connections. It discusses the role of cookies in tracking users and enhancing web experiences, as well as the use of web caches to improve response times and reduce server load. Additionally, it covers HTTP request and response formats, status codes, and the importance of web caching for efficient content delivery.

Uploaded by

yyogeshwar768
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views38 pages

WWW HTTP

The document provides an overview of the World Wide Web (WWW) and the HyperText Transfer Protocol (HTTP), detailing their architecture, functionality, and the differences between non-persistent and persistent connections. It discusses the role of cookies in tracking users and enhancing web experiences, as well as the use of web caches to improve response times and reduce server load. Additionally, it covers HTTP request and response formats, status codes, and the importance of web caching for efficient content delivery.

Uploaded by

yyogeshwar768
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

DATA COMMUNICATION AND NETWORKING

The WWW and HTTP

Dr. Veena S
Department of Computer Applications
DATA COMMUNICATION AND NETWORKING
World Wide Web (WWW)

▪ The idea of Web was first proposed by Tim Berners-Lee in


1989
▪ Goal was to share the research of different researchers at
different locations of Europe
▪ Commercial web started in early 1990s
▪ The Web is a repository of Web Pages distributed all over the
world and the related documents are linked
▪ To access the linked document we use the concept called
hypertext (now called as Hypermedia)
DATA COMMUNICATION AND NETWORKING
Architecture of the Web

▪ It is a distributed client-server service


▪ Service provided is distributed over many locations called
sites
▪ Each site holds one or more documents called Web pages
▪ Each Web page could be simple(No links) or
composite(one or more links to other Web pages)
▪ Each web page is a file with a name and address
▪ Web operates on demand
• Each object is addressable by a URL (has 2 parts)
• e.g. www.someschool.edu/someDept/pic.gif

host name path name


DATA COMMUNICATION AND NETWORKING
Example (Retrieving two files and one image)

▪ Assume we need to retrieve a scientific document that


contains one reference to another text file and one reference
to a large image
▪ The main document and the image are stored in two separate
files in the same site (file A and file B); the referenced text file
is stored in another site (file C)
▪ Since we are dealing with three different files, we need three
transactions if we want to see the whole document.
DATA COMMUNICATION AND NETWORKING
Example (Retrieving two files and one image)
DATA COMMUNICATION AND NETWORKING
HTTP – An Overview

▪ At the heart of the web we have HTTP protocol


▪ HTTP (HyperText Transfer Protocol) is a protocol used to
define how client server programs can be written to retrieve
web pages from the web
▪ It uses TCP at the Transport layer – no need to worry about
errors or loss
▪ The client side of HTTP contains Web browsers such as
Netscape Navigator, Firefox, Internet Explorer etc.
▪ The server side of HTTP is implemented in Web Servers such
as Apache, IIS (Internet Information Server), Nginx etc
▪ HTTP has several versions, HTTP/1.0(1990’s), HTTP/1.1 (1997),
recently today’s browsers started using HTTP/2(2015)
DATA COMMUNICATION AND NETWORKING
HTTP – An Overview

▪ HTTP client sends a request and HTTP


server returns a response
▪ Server has no information about previous
request
▪ When client re-requests the web page few
seconds after the previous request,
Server will send the page again
▪ It will not say that the page was served
just now (Stateless Protocol)
▪ client initiates TCP connection (creates socket) to server, port 80
▪ server accepts TCP connection from client
▪ HTTP messages exchanged between browser (HTTP client) and Web
server
▪ TCP connection closed
DATA COMMUNICATION AND NETWORKING
Non-persistent versus Persistent connection

▪ In a Non-persistent connection one TCP connection is made


for each request/response
1. Client opens the connection and sends a request
2. Server sends the response and closes the connection
3. Client reads the data until EOF marker and closes the
connection
▪ Overhead is too high
▪ In a Persistent connection the server leaves the connection
open after sending the response
▪ Server can close the connection at the request of the client or
timeout occurs
DATA COMMUNICATION AND NETWORKING
Non-persisitent versus Persistent connection

▪ Following figure shows an example of a nonpersistent


connection. The client needs to access a file that contains one
link to an image. The text file and image are located on the
same server
▪ Here we need two connections
▪ For each connection, TCP requires at least three handshake
messages to establish the connection, but the request can be
sent with the third one
▪ After the connection is established, the object can be
transferred
▪ After receiving an object, another three handshake messages
are needed to terminate the connection
DATA COMMUNICATION AND NETWORKING
Non-persistent versus Persistent
connection

2.10
DATA COMMUNICATION AND NETWORKING
Non-persisitent versus Persistent connection

▪ Following figure shows the same scenario as in previous


Example, but using a persistent connection.

▪ Only one connection establishment and connection


termination is used, but the request for the image is sent
separately.
DATA COMMUNICATION AND NETWORKING
Non-persistent versus Persistent connection

2.12
DATA COMMUNICATION AND NETWORKING
Non-persisitent versus Persistent connection

▪ Non-persistent HTTP
▪ At most one object sent over TCP connection
▪ connection then closed
▪ Downloading multiple objects required multiple connections
▪ Persistent HTTP
▪ Multiple objects can be sent over single TCP connection
between client, server
▪ HTTP version1.1 onwards it is persistent by default
DATA COMMUNICATION AND NETWORKING
Non-persisitent versus Persistent connection

▪ RTT (deffn: time for a small packet to travel from client to server and
back
HTTP response time in Non-persistent HTTP:
- one RTT to initiate TCP connection,
- one RTT for HTTP request and first few bytes of HTTP response to return
- file transmission time
▪ non-persistent HTTP response time = 2RTT+ file transmission time
▪ Today, browsers often open parallel TCP connections to fetch referenced
objects
persistent HTTP:
▪ server leaves connection open after sending response
▪ as little as one RTT for all the referenced objects
DATA COMMUNICATION AND NETWORKING
Formats of the request and response messages

▪ Request and Response


format
▪ Four sections
Request line / Status line
Header lines
Blank line
Body
▪ Data is in clear text
▪ Readable by humans
(ASCII format)
DATA COMMUNICATION AND NETWORKING
Formats of the request and response messages
DATA COMMUNICATION AND NETWORKING
Methods

url – 4/3 fields (protocol, host, port, path)


Version – HTTP 1.1

Head - used for debugging purpose


DATA COMMUNICATION AND NETWORKING
Request Header Names
DATA COMMUNICATION AND NETWORKING
Request and Response messages
Examples
GET /index.html HTTP/1.1\r\n
Host: www-net.cs.umass.edu\r\n
User-Agent: Firefox/3.6.10\r\n
Accept: text/html,application/xhtml+xml\r\n
Accept-Language: en-us,en;q=0.5\r\n
Accept-Encoding: gzip,deflate\r\n
Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n
Keep-Alive: 115\r\n
Connection: keep-alive\r\n
\r\n

carriage return, line feed at start


of line indicates end of header lines

Connection: Keep alive – persistent connection


Connection: Close - non-persistent connection
DATA COMMUNICATION AND NETWORKING
Response Header Names
DATA COMMUNICATION AND NETWORKING
Request and Response messages
Examples
HTTP/1.1 200 OK\r\n
Date: Sun, 26 Sep 2010 20:09:20 GMT\r\n
Server: Apache/2.0.52 (CentOS)\r\n
Last-Modified: Tue, 30 Oct 2007 17:00:02
GMT\r\n
ETag: "17dc6-a5c-bf716880"\r\n
Accept-Ranges: bytes\r\n
Content-Length: 2652\r\n
Keep-Alive: timeout=10, max=100\r\n
Connection: Keep-Alive\r\n
Content-Type: text/html; charset=ISO-8859-
1\r\n
\r\n
data data data data data ...

carriage return,
line feed at start
of line indicates
end of header lines
DATA COMMUNICATION AND NETWORKING
HTTP response status codes

1xx - Informational
Request received, continuing process
2xx - Success
Action successfully received, understood and
accepted
3xx - Redirection
Further action must be taken to complete the
request
4xx - Client Error
Request contains bad syntax or cannot be filled
5xx - Server Error
Src: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
Server failed to fulfill an apparently valid request
DATA COMMUNICATION AND NETWORKING
HTTP response status codes
▪ Status code appears in 1st line in server-to-client response
message
▪ some sample codes:
▪ 200 OK
▪ request succeeded, requested object later in this
msg
▪ 301 Moved Permanently
▪ requested object moved, new location specified later
in this msg (Location:)
▪ 400 Bad Request
▪ request msg not understood by server
▪ 404 Not Found
▪ requested document not found on this server
▪ 500 Internal Server Error
DATA COMMUNICATION AND NETWORKING
HTTP Examples

2
DATA COMMUNICATION AND NETWORKING
HTTP Examples
DATA COMMUNICATION AND NETWORKING
HTTP response status codes

▪ How does a browser/server decide which header line


to include?

▪ A browser will generate header lines as a function of


the browser type and version

▪ Even web servers behave similarly. Depending on the


versions and configurations, which header lines to be
included is decided
DATA COMMUNICATION AND NETWORKING
Conditional Request

▪ Client can add condition in its request


▪ Server will send the web page if the condition is met
The following example shows how a client imposes the
modification data and time condition on a request and the
response from the server
DATA COMMUNICATION AND NETWORKING
Cookies

▪ Cookies allow sites to keep track of users


▪ When the server receives the request from the client it
stores info like domain name, registration No. etc in a file or
string (creating cookie)
▪ Server includes the cookie in response and send to client
▪ Browser in client stores the cookie for further use
▪ First time cookie is set by server
▪ Browser sends cookie each time it makes a request
DATA COMMUNICATION AND NETWORKING
Cookies

▪ Usage of Cookies has four components:

▪ Cookie header line in the HTTP Response message (set


cookie)
▪ Cookie header line in the HTTP Request message
▪ A cookie file maintained by the browser
▪ A backend database at the web site (server side)
DATA COMMUNICATION AND NETWORKING
Cookies

client server

ebay 8734 usual http request msg Amazon server


cookie file creates ID
usual http response 1678 for user create backend
set-cookie: 1678 entry database
ebay 8734
amazon 1678
usual http request msg
cookie: 1678 cookie- access
specific
usual http response msg action

one week later:


ebay 8734 usual http request msg access
amazon 1678
cookie: 1678
cookie-
usual http response msg specific
action
DATA COMMUNICATION AND NETWORKING
Cookies

▪ Following figure shows a scenario in which an electronic store


can benefit from the use of cookies. Assume a shopper wants to
buy a toy from an electronic store named BestToys. The shopper
browser (client) sends a request to the BestToys server. The
server creates an empty shopping cart (a list) for the client and
assigns an ID to the cart (for example, 12343). The server then
sends a response message, which contains the images of all toys
available, with a link under each toy that selects the toy if it is
being clicked. This response message also includes the Set-
Cookie header line whose value is 12343. The client displays the
images and stores the cookie value in a file named BestToys.
DATA COMMUNICATION AND NETWORKING
Cookies
DATA COMMUNICATION AND NETWORKING
Cookies

what cookies can be used for:


▪ authorization
▪ shopping carts
▪ recommendations
▪ Advertisements

▪ cookies and privacy:


▪ cookies permit sites to learn a lot about
you
▪ you may supply name and e-mail to sites
▪ Keeping site information to an extent -
(in contrast to stateless protocol)
DATA COMMUNICATION AND NETWORKING
Web caches (proxy server)

goal: satisfy client request without involving origin server

▪ It is a computer that keeps


copies of responses to recent
requests proxy
▪ user sets browser: Web client server
accesses via cache
▪ browser sends all HTTP origin
server
requests to cache
▪object in cache: cache
returns object
▪else cache requests object
client
from origin server, then
returns object to client
DATA COMMUNICATION AND NETWORKING
Web caches (proxy server)

▪ cache acts as both client and server


▪server for original requesting client
▪client to origin server
▪ typically cache is installed by ISP
(university, company, residential ISP)
▪ why Web caching?
▪ reduce response time for client request
▪ reduce traffic on an institution’s access
link
▪ Internet dense with caches: enables
“poor” content providers to effectively
deliver content (so too does p2p file
sharing)
DATA COMMUNICATION AND NETWORKING
Web caches (proxy server) Example
DATA COMMUNICATION AND NETWORKING
Web caches (proxy server)

▪ How long the response should remain in proxy?

▪ Different strategies are used Eg: news page everyday


early morning access and keep it until next day

▪ Add different headers (to give more info)

▪ Security – HTTP no security, if required use HTTPs


THANK YOU

Dr. Veena S, Chairperson


Department of Computer Applications
[email protected]

+91 80 26721983 Extn 829

You might also like