0% found this document useful (0 votes)
34 views

Two Types of HTTP Messages:: Request Response

total delay reduced from minutes to 2 sec + milliseconds

Uploaded by

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

Two Types of HTTP Messages:: Request Response

total delay reduced from minutes to 2 sec + milliseconds

Uploaded by

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

HTTP request message

 two types of HTTP messages: request, response


 HTTP request message:
 ASCII (human-readable format)

request line
(GET, POST, GET /somedir/page.html HTTP/1.1
HEAD commands) Host: www.someschool.edu
User-agent: Mozilla/4.0
header Connection: close
lines Accept-language:fr

Carriage return,
line feed (extra carriage return, line feed)
indicates end
of message
2: Application Layer 1
HTTP request message: general format

2: Application Layer 2
Uploading form input
Post method:
 Web page often
includes form input URL method:
 Input is uploaded to  Uses GET method
server in entity body  Input is uploaded in
URL field of request
line:

www.somesite.com/animalsearch?monkeys&banana

2: Application Layer 3
Method types
HTTP/1.0 HTTP/1.1
 GET  GET, POST, HEAD
 POST  PUT
 HEAD  uploads file in entity
body to path specified
 asks server to leave
in URL field
requested object out of
response  DELETE
 deletes file specified in
the URL field

2: Application Layer 4
HTTP response message
status line
(protocol
status code HTTP/1.1 200 OK
status phrase) Connection close
Date: Thu, 06 Aug 1998 12:00:15 GMT
header Server: Apache/1.3.0 (Unix)
lines Last-Modified: Mon, 22 Jun 1998 …...
Content-Length: 6821
Content-Type: text/html

data, e.g., data data data data data ...


requested
HTML file

2: Application Layer 5
HTTP response status codes
In first line in server->client response message.
A few sample codes:
200 OK
 request succeeded, requested object later in this message
301 Moved Permanently
 requested object moved, new location specified later in
this message (Location:)
400 Bad Request
 request message not understood by server
404 Not Found
 requested document not found on this server
505 HTTP Version Not Supported
2: Application Layer 6
Trying out HTTP (client side) for yourself

1. Telnet to your favorite Web server:


telnet cis.poly.edu 80 Opens TCP connection to port 80
(default HTTP server port) at cis.poly.edu.
Anything typed in sent
to port 80 at cis.poly.edu

2. Type in a GET HTTP request:


GET /~ross/ HTTP/1.1 By typing this in (hit carriage
Host: cis.poly.edu return twice), you send
this minimal (but complete)
GET request to HTTP server

3. Look at response message sent by HTTP server!

2: Application Layer 7
User-server state: cookies
Example:
Many major Web sites
 Susan always access
use cookies
Internet always from PC
Four components:
 visits specific e-
1) cookie header line of
HTTP response message commerce site for first
2) cookie header line in time
HTTP request message  when initial HTTP
3) cookie file kept on
user’s host, managed by requests arrives at site,
user’s browser site creates:
4) back-end database at  unique ID
Web site
 entry in backend
database for ID

2: Application Layer 8
Cookies: keeping “state” (cont.)
client server
ebay 8734
usual http request msg
Amazon server
cookie file usual http response creates ID
Set-cookie: 1678 1678 for user create
ebay 8734 entry
amazon 1678
usual http request msg
cookie: 1678 cookie- access
specific
one week later: usual http response msg action backend
database
access
ebay 8734 usual http request msg
amazon 1678 cookie: 1678 cookie-
spectific
usual http response msg action

2: Application Layer 9
Cookies (continued)
aside
What cookies can bring: Cookies and privacy:
 authorization  cookies permit sites to
 shopping carts learn a lot about you
 you may supply name
 recommendations
and e-mail to sites
 user session state
(Web e-mail)
How to keep “state”:
 protocol endpoints: maintain state
at sender/receiver over multiple
transactions
 cookies: http messages carry state

2: Application Layer 10
Web caches (proxy server)
Goal: satisfy client request without involving origin server

 user sets browser: Web origin


server
accesses via cache
 browser sends all HTTP Proxy
HT
requests to cache TP
req server q uest
H u P re
T
client TP e st T T o n se
 object in cache: cache res H
r es
p
pon P
returns object se H TT
e st
 else cache requests r eq
u
object from origin server, T P o nse
HT p
r es
then returns object to T TP
client H

client
origin
server

2: Application Layer 11
More about Web caching
 cache acts as both Why Web caching?
client and server  reduce response time
 typically cache is for client request
installed by ISP  reduce traffic on an
(university, company, institution’s access
residential ISP) link.
 Internet dense with
caches: enables “poor”
content providers to
effectively deliver
content (but so does
P2P file sharing)
2: Application Layer 12
Caching example
origin
Assumptions servers
 average object size = 100,000
bits public
Internet
 avg. request rate from
institution’s browsers to origin
servers = 15/sec
 delay from institutional router to 1.5 Mbps
any origin server and back to access link
router = 2 sec
institutional
Consequences network
10 Mbps LAN
 utilization on LAN = 15%
 utilization on access link = 100%
 total delay = Internet delay + access
delay + LAN delay institutional
= 2 sec + minutes + milliseconds cache

2: Application Layer 13
Caching example (cont)
origin
possible solution servers
 increase bandwidth of access
public
link to, say, 10 Mbps Internet
consequence
 utilization on LAN = 15%
 utilization on access link = 15% 10 Mbps
 Total delay = Internet delay + access link
access delay + LAN delay institutional
= 2 sec + msecs + msecs network
10 Mbps LAN
 often a costly upgrade

institutional
cache

2: Application Layer 14
Caching example (cont)
origin
possible solution: install servers
cache public
 suppose hit rate is 0.4 Internet
consequence
 40% requests will be
satisfied almost immediately
 60% requests satisfied by 1.5 Mbps
access link
origin server
 utilization of access link institutional
reduced to 60%, resulting in network
10 Mbps LAN
negligible delays (say 10
msec)
 total avg delay = Internet
delay + access delay + LAN institutional
delay = .6*(2.01) secs + . cache
4*milliseconds < 1.4 secs

2: Application Layer 15
Conditional GET

 Goal: don’t send object if cache server


cache has up-to-date cached HTTP request msg
version If-modified-since:
object
 cache: specify date of <date>
not
cached copy in HTTP request modified
HTTP response
If-modified-since: HTTP/1.0
<date> 304 Not Modified
 server: response contains no
object if cached copy is up-
HTTP request msg
to-date: If-modified-since:
HTTP/1.0 304 Not <date> object
Modified modified
HTTP response
HTTP/1.0 200 OK
<data>
2: Application Layer 16

You might also like