HTTP Protocol - Krypton Guide

Download Report

Transcript HTTP Protocol - Krypton Guide

HTTP Protocol
Amanda Burrows
HTTP Protocol

The HTTP protocol is used to send HTML
documents through the Internet. The HTTP
protocol sends the HTML documents in packets,
using TCP/IP. With each packet, the HTTP
protocol attaches a header, which contains
information such as the name and location of
the page being requested, the name and IP
address of the remote server that contains the
Web page, the IP address of the local client, the
HTTP version number, and the URL of the
referring page. This information is referred to as
the server variables.
Information

The Hypertext Transfer Protocol (HTTP) is an applicationlevel protocol with the lightness and speed necessary for
distributed, collaborative, hypermedia information
systems. HTTP has been in use by the World-Wide Web
global information initiative since 1990.
HTTP version 1.0 is a stateless protocol
 HTTP 1.1 is stateful

Improvements in HTTP 1.1
Requests include a Host MIME header so that
one web server can easily serve different sites at
different URLs.
 Servers and browsers can exchange compressed
files and particular byte ranges of a document,
both of which can decrease network traffic.
 HTTP 1.1 is designed to work much better with
proxy servers
 HTTP 1.1 is a strict superset of HTTP 1.0, so
HTTP 1.1 web servers have no trouble
interacting with older browsers that speak only
HTTP 1.0

HTTP
HTTP, the Hypertext Transfer Protocol, is the
standard protocol for communication between
web browsers and web servers. HTTP specifies
how a client and server establish a connection,
how the client requests data from the server,
how the server responds to that request, and
finally how the connection is closed. HTTP
connections use the TCP/IP protocol for data
transfer.
Step 1
HTTP 1.0 is the currently accepted version of the
protocol. It uses MIME to encode data. The basic
protocol defines a sequence of four steps for each
request from a client to the server:
Making the connection. The client establishes a
TCP connection to the server, on port 80 by default;
other ports may be specified in the URL.
Step 2
Making a request. The client sends a
message to the server requesting the page at
a specified URL. The format of this request is
typically something like:
GET /index.html HTTP 1.0
Request-Line
The Request-Line begins with a method token, followed by the
Request-URI and the protocol version, and ending with CRLF.
The elements are separated by SP characters. No CR or LF are
allowed except in the final CRLF sequence.
Request-Line = Method SP Request-URI SP HTTP-Version CRLF
* Note that the difference between a Simple-Request and the
Request-Line of a Full-Request is the presence of the HTTPVersion field and the availability of methods other than GET.
Method
The Method token indicates the method to be performed on the
resource identified by the Request-URI. The method is casesensitive.
Method = "GET" ;
| "HEAD" ;
| "POST" ;
| extension-method
extension-method = token
The list of methods acceptable by a specific resource can change
dynamically; the client is notified through the return code of the
response if a method is not allowed on a resource. Servers should
return the status code 501 (not implemented) if the method is
unrecognized or not implemented.
GET

The GET method means retrieve whatever information is identified
by the Request-URI. If the Request-URI refers to a data-producing
process, it is the produced data which shall be returned as the
entity in the response and not the source text of the process, unless
that text happens to be the output of the process.

The semantics of the GET method changes to a "conditional GET" if
the request message includes an If-Modified-Since header field. A
conditional GET method requests that the identified resource be
transferred only if it has been modified since the date given by the
If-Modified-Since header.

The conditional GET method is intended to reduce network usage by
allowing cached entities to be refreshed without requiring multiple
requests or transferring unnecessary data.
Head
The HEAD method is identical to GET except that the server must
not return any Entity-Body in the response. The metainformation
contained in the HTTP headers in response to a HEAD request
should be identical to the information sent in response to a GET
request. This method can be used for obtaining metainformation
about the resource identified by the Request-URI without
transferring the Entity-Body itself. This method is often used for
testing hypertext links for validity, accessibility, and recent
modification.
There is no "conditional HEAD" request analogous to the conditional
GET. If an If-Modified-Since header field is included with a HEAD
request, it should be ignored.
Post




The POST method is used to request that the
destination server accept the entity enclosed in the
request as a new subordinate of the resource identified
by the Request-URI in the Request-Line. POST is
designed to allow a uniform method to cover the
following functions:
Annotation of existing resources;
Posting a message to a bulletin board, newsgroup,
mailing list, or similar group of articles;
Providing a block of data, such as the result of
submitting a form, to a data-handling process;
Extending a database through an append operation.
Step 3
The response. The server sends a
response to the client. The response
begins with a response code, followed by
MIME header information, then a blank
line, then the requested document or an
error message. Assuming the requested
file is found, a typical response looks like
this:
Step 3 (cont)
HTTP 1.0 200 OK
Server: NCSA/1.4.2
MIME-version: 1.0
Content-type: text/html
Content-length: 107
<html>
<Head>
<Title>
A Sample HTML file
</Title>
</Head>
<body>
The rest of the document goes here
</body>
</html>
Step 4
Closing the connection. Either client or the
server or both close the connection. Thus, a
separate network connection is used for each
request. If the client reconnects, the server
retains no memory of past requests is called
stateless; in contrast, a stateful protocol such
as FTP can process many requests before the
connection is closed. The lack of state is both
a strength and a weakness of HTTP.
Example of connections…
Imagine that you are browsing a Web page and have just clicked on a link
whose URL is http://www.cob.mnsu.edu/faculty.html. The following
sequence of events will take place to let you access that page:
•
•
•
•
•
Your Web browser will determine the URL associated with the link and will
extract the name of the machine to which it must connect – in this case,
www.cob.mnsu.edu.
The browser will use the TCP/IP protocols to establish a connection across
the Internet between your computer and www.cob.mnsu.edu.
When the connection between these two machines has been established,
your browser will send a special HTTP message called GET, which indicates
that it wants the destination machine to retrieve a page. The GET
command contains the name of the desired page, in this case “faculty.html.”
The remote machine www.cob.mnsu.edu locates the file name in the GET
message, reads it, copies it, and returns the copy to your browser, again
using TCP/IP and the Internet.
Your browser receives the page and displays its contents on your screen.
Multipurpose Internet Mail Extensions
MIME is an open standard for sending
multipart, multimedia data through
Internet email.
 Originally intended for email
 Content types are classified at two levels:
a type and a subtype

HTTP communication
Most HTTP communication is initiated by a
user agent and consists of a request to be
applied to a resource on some original
server.
 A more complicated situation occurs when
one or more intermediaries are present in
the request/response chain.

Three common forms:
Proxy – is a forwarding agend, receiving
requests for a URI in its absolute form, rewriting
all or parts of the message, and forwarding the
reformatted request toward the server identified
by the URI
 Gateway – is a receiving agent, acting as a layer
above some other server and, if necessary,
translating the requests to the underlying
server’s protocol
 Tunnel – acts as a relay point between two
connections without changing the messages

Any Questions??