Escolar Documentos
Profissional Documentos
Cultura Documentos
Protocol
By:
Manish Kumar
Pilani (Rajasthan) India
manishkulhari@gmail.com
Common Protocols
In order for two remote machines to
understand each other they should
speak the same language
coordinate their talk
HTTP
Request
HTTP
Request
Proxy Server
HTTP
Response
HTTP Response
Web Server
http://www.cs.huji.ac.il/~dbi
http://www.cs.huji.ac.il/~dbi
www.cs.huji.ac.il:80
File System
manishkulhari@gmail.com
Department
Proxy Server
University
Proxy Server
Israel
Proxy Server
Web Server
manishkulhari@gmail.com
www.w3.org:80
5
Terminology
User agent: client which initiates a request
(browser, editor, Web robot, )
Origin server: the server on which a given
resource resides (Web server a.k.a. HTTP
server)
Proxy: acts as both a server and a client
Gateway: server which acts as intermediary
for other servers
Tunnel: acts as a blind relay between two
applications we can implement a custom
protocol using HTTP tunneling
manishkulhari@gmail.com
Resources
A resource is a chunk of information
that can be identified by a URL
(Universal Resource Locator)
A resource can be
A file
A dynamically created page
In a URL
Spaces are represented by +
Characters such as &,+,% are encoded
in the form %xx where xx is the ascii
value in hexadecimal; For example, &
= %26
The inputs to the parameters are given
as a list of pairs of a parameter and a
value:
var1=value1&var2=value2&var3=value3
manishkulhari@gmail.com
war&peace Tolstoy
manishkulhari@gmail.com
10
http://www.google.com/search?hl=en&q=war%26peace+Tolstoy
manishkulhari@gmail.com
11
An HTTP Session
A basic HTTP session has four phases:
1.Client opens the connection (a TCP
connection)
2.Client makes a request
3.Server sends a response
4.Server closes the connection
manishkulhari@gmail.com
12
Nesting
in
Page
Index.html
Left frame
Jumping fish
Right frame
Fairy icon
HUJI icon
What
What we
we see
see on
on the
the browser
browser can
can be
be
aa combination
combination of
of several
several resources
resources
manishkulhari@gmail.com
13
Nested Objects
Suppose a client accesses a page containing
10 inline images, how many sessions will be
required to display the page completely?
The answer is 11 HTTP sessions why?
Some browsers/servers support a feature
called keep-alive which can keep the
connection open until it is explicitly closed
How can this help?
manishkulhari@gmail.com
14
Stateless Protocol
HTTP is a stateless protocol, which means
that once a server has delivered the
requested data to a client, the server retains
no memory of what has just taken place
(even if the connection is keep-alive)
What are the difficulties in working with a
stateless protocol?
How would you implement a site for buying
some items?
So why dont we have states in HTTP?
manishkulhari@gmail.com
15
An initial line
Zero or more header lines
A blank line (i.e., a CRLF by itself), and
An optional message body (e.g., a file, query
data, or query output)
Note: CRLF = \r\n
(usually ASCII 13 followed by ASCII 10)
manishkulhari@gmail.com
16
Headers
HTTP 1.0 defines 16 headers
None are required
How do we
know who is
the host when
there is no host
header?
17
HTTP Requests
manishkulhari@gmail.com
18
The
The Format
Format of
of aa Request
Request
method
header
sp
:
URL
value
sp version
cr lf
cr
lf
headers
lines
header
cr lf
value
cr
lf
Entity Body
manishkulhari@gmail.com
19
Request Example
GET /index.html HTTP/1.1 [CRLF]
Accept: image/gif, image/jpeg [CRLF]
User-Agent: Mozilla/4.0 [CRLF]
Host: www.cs.huji.ac.il:80 [CRLF]
Connection: Keep-Alive [CRLF]
[CRLF]
manishkulhari@gmail.com
20
method
Request Example
request URL
GET /index.html HTTP/1.1
version
Accept: image/gif, image/jpeg
User-Agent: Mozilla/4.0
Host: www.cs.huji.ac.il:80
Connection: Keep-Alive
[blank line here]
headers
manishkulhari@gmail.com
21
Request Methods
manishkulhari@gmail.com
22
23
24
GET Request
A request to get a resource from the
Web
The most frequently used method
The request has no message body, but
parameters can be sent in the request
URL (i.e., the URL without the host
part)
manishkulhari@gmail.com
25
HEAD Request
A HEAD request asks the server to return the
response headers only, and not the actual
resource (i.e., no message body)
This is useful for checking characteristics of a
resource without actually downloading it, thus
saving bandwidth
Used for testing hypertext links for validity,
accessibility and recent modification
manishkulhari@gmail.com
26
Post Request
POST request can send data to the
server
POST is mostly used in form-filling
The data filled into the form are translated
by the browser into some special format
and sent to a program on the server using
the POST command
manishkulhari@gmail.com
27
28
Post Example
Here's a typical form submission, using
POST:
POST /path/register.cgi HTTP/1.0
From: frog@cs.huji.ac.il
User-Agent: HTTPTool/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 35
home=Ross+109&favorite+flavor=flies
manishkulhari@gmail.com
29
Request Headers
manishkulhari@gmail.com
30
Accept
Accept-Encoding
Authorization
Connection
Cookie
Host
If-Modified-Since
Referer
User-Agent
manishkulhari@gmail.com
31
Accept-Encoding
Indicates encodings (e.g., gzip) client can
handle
manishkulhari@gmail.com
32
manishkulhari@gmail.com
33
manishkulhari@gmail.com
34
35
Content-Length
Request Header
This header is only applicable to
POST requests
It specifies the size of the POST
data in bytes
manishkulhari@gmail.com
36
manishkulhari@gmail.com
37
38
If-Modified-Since
Request Header
This header indicates that client
wants the page only if it has been
changed after the specified data
If-Unmodified-Since is the reverse of
If-Modified-Since
It is used for PUT requests (update
this document only if nobody else has
changed it since I generated it)
manishkulhari@gmail.com
39
manishkulhari@gmail.com
40
41
manishkulhari@gmail.com
42