Вы находитесь на странице: 1из 28

HTTP – Hypertext Transfer Protocol

PONDU
MTECH CSE

1
Introduction

• Transfer protocol used throughout the


WWW
• is a request-response protocol
• it is stateless
• latest version is HTTP/1.1
• runs on top of TCP on the standardized
port 80

2
conti…

• Specifies what messages client may send


to servers and what response they get
back
• Each interaction consists of one ASCII
request followed by one RFC 822 MIME
like response
• All client and servers must obey this
protocol

3
connections

• In http 1.0, after the connection


established, a single request sent over
and a single response sent back
• It is efficient for normal web page
containing html text
• When web page contain large no of icons,
images etc, establishing a TCP connection
to transport a single icon become very
expensive

4
Conti….

• HTTP 1.1 support persistent connections


• establish a TCP connection send a
request and get a response
• Then send additional requests and get
additional responses
• The relative overload due to TCP is much
less per request
• It is possible to pipeline the requests

5
Methods

• Although HTTP was designed for use in


the Web, it has been intentionally made to
future object-oriented applications.
• so operations, called methods, other than
just requesting a Web page are supported
• Each request consists of one or more lines
of ASCII text, with first word on first line
being the name of the method requested.

6
Conti…

• The names are case sensitive


• The methods are:
• GET method
requests the server to send the page.
page is suitably encoded in MIME.
vast majority of requests to Web servers are
GETs.
The usual form of GET is
GET filename HTTP/1.1

7
conti…

• HEAD method:
asks for the message header, without the
actual page
used to get a page's time of last modification,
to collect information for indexing purposes
to test a URL for validity.

8
Conti….

• PUT method:
reverse of GET
instead of reading the page, it writes the page
makes it possible to build a collection of Web
pages on a remote server
request contains the page
It may be encoded using MIME

9
Conti….

• POST method:
PUT is similar to POST method.
 bears a URL, but instead of replacing the
existing data, the new data is ''appended'' to it
neither PUT nor POST is used very much.

10
Conti….

• DELETE method:
it removes the page.
authentication and permission play a major
role
There is no guarantee that DELETE succeeds
Because even if the remote HTTP server is
willing to delete the page, the underlying file
may have a mode that forbids the HTTP
server from modifying

11
Conti….

• TRACE method:
 for debugging
instructs the server to send back the request
 useful when requests are not being
processed correctly and the client wants to
know what request the server actually got.

12
Conti….

• CONNECT method:
reserved for future use.

• OPTIONS method:
provides a way for the client to query the
server about its properties or those of a
specific file

13
The built-in HTTP request methods
Method Description
GET Request to read a Web page

HEAD Request to read a Web page’s header

PUT Request to store a Web page

POST Append to a named recourse

DELETE Remove the Web page

TRACE Echo the incoming request

CONNECT Reserved for future use

OPTIONS Query certain options

14
Status lines

• Every request gets a response consisting


of a status line, and possibly additional
information
• It contains a three-digit status code telling
whether the request was satisfied, and if
not, why not
• first digit is used to divide the responses
into five major groups

15
The status code response groups

Code Meaning Example


1xx Information 100=server agrees to handle clients
request
2xx Success 200=request succeeded;204=no
content present
3xx Redirection 301=page moved;304=cached page
still valid
4xx Client error 403=forbidden page;404=page not
found
5xx Server error 500=internal server error;503=try
again later

16
Message Headers

• request line may be followed by additional


lines with more information called request
headers
• Responses may also have response
headers
• Some headers can be used in either
direction

17
HTTP message headers
Conti….

• User-Agent header allows the client to


inform the server about its browser, os,
and other properties
• It is used by the client to provide the
server with the information
• four Accept headers tell the server what
the client is willing to accept in the event

19
Conti….

• Accept header specifies the MIME types


that are welcome
• Accept-Charset header gives the
character set
• Accept-encode header deals with
compression methods
• Accept-Language header indicates a
natural language

20
Conti….
• If the server has a choice of pages, it can
use this information to supply the one the
client is looking for
• If it is unable to satisfy the request, an
error code is returned and the request fails
• Host header names the server
• It is taken from the URL
• This header is mandatory

21
Conti….

• It is used because some IP addresses


may serve multiple DNS names and the
server needs some way to tell which host
to hand the request to.
• Authorization header is needed for
pages that are protected
• client may have to prove it has a right to
see the page requested.

22
Conti….

• Although cookies are dealt with in RFC


2109 rather than RFC 2616, they also
have two headers
• Cookie header is used by clients to return
to server a cookie that was previously sent
by some machine in server's domain
• Date header can be used in both
directions and contains the time and date
the message was sent

23
Conti….

• Upgrade header is used to make it easier


to make the transition to a future version
of the HTTP protocol.
• It allows the client to announce what it can
support and the server to assert what it is
using.
• Server, allows the server to tell who it is
and some of its properties if it wishes.

24
Conti….
• next four headers, all starting with
Content-, allow the server to describe
properties of page it is sending.
• Last-Modified header tells when the
page was last modified.
• This header plays an important role in
page caching.

25
Conti….

• Location header can be used if the page


has moved or to allow multiple URLs to
refer to the same page
• If a page is very large, a small client may
not want it all at once
• Some servers will accept requests for byte
ranges, so page can be fetched in multiple
small units.

26
Conti….

• Accept-Ranges header announces


server's willingness to handle this type of
partial page request.
• Set-Cookie, is how servers send cookies
to clients.
• client is expected to save the cookie and
return it on subsequent requests to the
server.

27
THANK YOU

28