Application HTTP
Application HTTP
HTTP: Introduction
Srinivas Narayana
1
Review of concepts
IP
Network
4
HTTP Protocol Overview
HTTP overview
HTTP: hypertext transfer HT
TP
protocol HT
r equ
est
PC running TP
• Client/server model res
p ons
Chrome e
• Client: browser that requests,
receives, “displays” Web objects e st
u
eq
• Server: Web server sends TTP
r
o ns
e
H es
p Web Server
objects in response to requests TP r
HT e.g., Apache HTTP
• HTTP 1.0: RFC 1945 server, nginx, etc.
• HTTP 1.1: RFC 2068
Mac running
Safari
6
Client server connection
DNS
Hostname IP address
Cs.Rutgers.edu 10.0.1.2
Host name
IP Address
HTTP application
IP Address, 80 typically
associated with
HTTP reques
t port 80
HTTP response
HTTP messages 7
HTTP messages: request message
• ASCII (human-readable format)
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14
9
HTTP method types
• GET • PUT
• Get the resource specified in the
requested URL. URL may refer to a • Update a resource at the requested
data-handling process URL with the new entity specified in
the entity body
• POST • DELETE
• Send entities (specified in the entity
body) to a data-handling process at the • Deletes file specified in the URL
requested URL
• HEAD • ... and other methods.
• Asks server to leave requested object
out of response, but send the rest of
the response
10
Difference between POST and PUT
• POST: the URL of the request • PUT: the URL of the request
identifies the resource that identifies the resource that is
processes the entity body contained in the entity body
https://tools.ietf.org/html/rfc2616
Difference between HEAD and GET
https://tools.ietf.org/html/rfc2616
Uploading form input: GET and POST
POST method: GET method:
• Web page often includes form • Entity body is empty
input • Input is uploaded in URL field of request
• Input is uploaded to server in line
entity body
• Example:
• Posted content not visible in • http://site.com/form?first=jane&last=austen
the URL
• Free form content (ex: images)
can be posted since entity body
interpreted as data bytes
13
Observing HTTP GET and POST
• A small demo
HTTP Response: General format
Unlike HTTP
request, No
method
name
15
HTTP message: 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
Server: Apache/1.3.0 (Unix)
response Last-Modified: Mon, 22 Jun 1998 …...
header Content-Length: 6821
lines Content-Type: text/html
Srinivas Narayana
20
Additional details about HTTP
• Persistent vs. Nonpersistent HTTP connections
• Cookies (User-server state)
• Web caches
21
Non/Persistent HTTP
HTTP connections
Persistent HTTP
Non-persistent HTTP
• Multiple
At most one
objects
object
canisbe
sent
sent
over
over
a TCP
singleconnection.
TCP connection
between client and server.
• HTTP/1.0 uses nonpersistent HTTP
• HTTP/1.1 uses persistent connections in default mode
23
Non-persistent HTTP
time
24
Non-persistent HTTP (contd.)
25
Non-Persistent HTTP’s Response time
Round Trip Time (RTT): time to send a
packet from client to server and back.
• Sum of propagation, transmission,
and queueing delays along both
directions. initiate TCP
connection
Response time: RTT
• One RTT to initiate TCP connection request
file
• One RTT for HTTP request and first time to
RTT
few bytes of HTTP response to return transmit
file
• File transmission time file
received
total = 2RTT + file transmission time
time time
26
Persistent HTTP: jumping to steps 4/5
time
The 10 objects can be requested over
the same TCP connection.
i.e., save an RTT trying to open a new
TCP connection per object.
27
Persistent vs. Non-persistent
Non-persistent HTTP requires at least 2 RTTs per object.
• For each object: Open TCP connection; send HTTP request & receive
response
ss
one week later: response
ce
ac
Cookie file http request (no auth)
cookie-
Netflix: 436 cookie: 1678
specific
Amazon: 1678 Personalized http action
response
31
How cookies work
Four components:
1. cookie header line of HTTP response message
2. cookie header line in HTTP request message
3. cookie file kept on user endpoint, managed by user’s browser
4. back-end database maps cookie to user data at Web endpoint
32
PSA: Cookies and Privacy
• The Internet would be unusable without cookies.
• However, cookies permit sites to learn a lot about
you, from your behaviors.
• E.g., which products, topics, images, etc. are you
most interested in?
• What demographic do you belong to? Where?
• What kinds of ads will you likely click on?
• Tracking networks correlate this info across sites
• You might reasonably be concerned about your
privacy when online.
• Disable and delete unnecessary cookies by default
• Use privacy-conscious browsers, websites, tools:
DuckDuckGo, Brave, AdBlock Plus. 33
Caching in HTTP
Web caches
Web caches: Machines that remember web responses for a network
35
Web caching using a proxy server
• You can configure a HTTP
proxy on your laptop’s network
Clients settings.
• If you do, your browser sends
all HTTP requests to the proxy
Web Server (cache).
GET foo.html (also called • Hit: cache returns object
GET foo.html origin server in
this context) • Miss:
• cache requests object from origin
Proxy server
Server The Internet • caches it locally
• and returns it to client
Store foo.html
on receiving
response 36
Web Caches: how does it look on HTTP?
cache server
• Conditional GET HTTP request msg
guarantees cache content If-modified-since:
object
is up-to-date while still <date>
not
saves traffic and response modified
HTTP response
time whenever possible HTTP/1.0
304 Not Modified
Uses
• Reduce bandwidth requirements on content provider
• Reduce $$ to maintain origin servers
• Reduce traffic on a network’s Internet connection, e.g.,
Rutgers
• Improve response time to user for a service
38
Without CDN DOMAIN NAME IP ADDRESS
www.yahoo.com 98.138.253.109
cs.rutgers.edu 128.6.4.2
www.google.com 74.125.225.243
www.princeton.edu 128.112.132.86
Implement DNS
CDN Name Server (124.8.9.8)
delegation to the DOMAIN NAME IP ADDRESS
Custom
CDN name server. www.yahoo.com 12.1.2.3 logic to
“layer of indirection”
www.yahoo.com 12.1.2.4 map ONE
www.yahoo.com 12.1.2.5
www.yahoo.com 12.1.2.6
domain
name to
one of
12.1.2.3 many IP
12.1.2.4
CDN servers addresses!
12.1.2.6 12.1.2.5
128.6.4.2
Origin server
42