Sie sind auf Seite 1von 5

HTTP PROTOCOL

SOLANKI HARDIK

I. INTRODUCTION added over the years to simulate server-initiated messages).


Designed in the early 1990s, HTTP is an extensible To present a Web page, the browser sends an original request
protocol which has evolved over time. It is an application to fetch the HTML document that represents the page. It then
layer protocol that is sent over TCP, or over a TLS-encrypted parses this file, making additional requests corresponding to
TCP connection, though any reliable transport protocol could execution scripts, layout information (CSS) to display, and
theoretically be used. Due to its extensibility, it is used to sub-resources contained within the page (usually images and
not only fetch hypertext documents, but also images and videos). The Web browser then mixes these resources to
videos or to post content to servers, like with HTML form present to the user a complete document, the Web page.
results. HTTP can also be used to fetch parts of documents Scripts executed by the browser can fetch more resources
to update Web pages on demand. HTTP means HyperText in later phases and the browser updates the Web page
Transfer Protocol. HTTP is the underlying protocol used by accordingly. A Web page is a hypertext document. This
the World Wide Web and this protocol defines how messages means some parts of displayed text are links which can
are formatted and transmitted, and what actions Web servers be activated (usually by a click of the mouse) to fetch a
and browsers should take in response to various commands. new Web page, allowing the user to direct their user-agent
HTTP is a protocol which allows the fetching of resources, and navigate through the Web. The browser translates these
such as HTML documents. It is the foundation of any data directions in HTTP requests, and further interprets the HTTP
exchange on the Web and it is a client-server protocol, which responses to present the user with a clear response.
means requests are initiated by the recipient, usually the B. The Web server
Web browser. For example, when you enter a URL in your
browser, this actually sends an HTTP command to the Web On the opposite side of the communication channel, is
server directing it to fetch and transmit the requested Web the server, which serves the document as requested by the
page. The other main standard that controls how the World client. A server appears as only a single machine virtually:
Wide Web works is HTML, which covers how Web pages this is because it may actually be a collection of servers,
are formatted and displayed. sharing the load (load balancing) or a complex piece of
software interrogating other computers (like cache, a DB
II. COMPONENTS OF HTTP BASED SYSTEMS server, or e-commerce servers), totally or partially generating
HTTP is a client-server protocol: requests are sent by one the document on demand. A server is not necessarily a single
entity, the user-agent (or a proxy on behalf of it). Most machine, but several server software instances can be hosted
of the time the user-agent is a Web browser, but it can on the same machine. With HTTP/1.1 and the Host header,
be anything, for example a robot that crawls the Web to they may even share the same IP address.
populate and maintain a search engine index. Each individual C. Proxies
request is sent to a server, which handles it and provides an
answer, called the response. Between the client and the server Between the Web browser and the server, numerous
there are numerous entities, collectively called proxies, which computers and machines relay the HTTP messages. Due
perform different operations and act as gateways or caches, to the layered structure of the Web stack, most of these
for example. operate at the transport, network or physical levels, becoming
HTTP is on top, at the application layer. Although impor- transparent at the HTTP layer and potentially making a
tant to diagnose network problems, the underlying layers are significant impact on performance. Those operating at the
mostly irrelevant to the description of HTTP. application layers are generally called proxies. These can be
transparent, forwarding on the requests they receive without
A. Client: the user-agent altering them in any way, or non-transparent, in which case
Client: the user-agent The user-agent is any tool that acts they will change the request in some way before passing it
on the behalf of the user. This role is primarily performed by along to the server. Proxies may perform numerous functions:
the Web browser; other possibilities are programs used by 1) caching (the cache can be public or private, like the
engineers and Web developers to debug their applications. browser cache) 2) filtering (like an antivirus scan or parental
The browser is always the entity initiating the request. It controls) 3) load balancing (to allow multiple servers to serve
is never the server (though some mechanisms have been the different requests) 4) authentication (to control access
to different resources) 5) logging (allowing the storage of
HARSHIL MAHAVADIA BATCH-H4 ENROLL-180173107016, historical information)
III. BASIC ASPECTS OF HTTP IV. W HAT CAN BE CONTROLLED BY HTTP
HTTP is generally designed to be simple and human read- This extensible nature of HTTP has, over time, allowed
able, even with the added complexity introduced in HTTP/2 for more control and functionality of the Web. Cache or au-
by encapsulating HTTP messages into frames. HTTP mes- thentication methods were functions handled early in HTTP
sages can be read and understood by humans, providing history. The ability to relax the origin constraint, by contrast,
easier testing for developers, and reduced complexity for has only been added in the 2010s. Here is a list of common
newcomers. features controllable with HTTP.
• Caching How documents are cached can be controlled by
A. HTTP is extensible HTTP. The server can instruct proxies and clients, about
Introduced in HTTP/1.0, HTTP headers make this protocol what to cache and for how long. The client can instruct
easy to extend and experiment with. New functionality can intermediate cache proxies to ignore the stored document.
even be introduced by a simple agreement between a client • Relaxing the origin constraint To prevent snooping and other
and a server about a new header’s semantics. privacy invasions, Web browsers enforce strict separation
between Web sites. Only pages from the same origin can
B. HTTP is stateless, but not sessionless
access all the information of a Web page. Though such
HTTP is called a stateless protocol because each command constraint is a burden to the server, HTTP headers can relax
is executed independently, without any knowledge of the this strict separation on the server side, allowing a document
commands that came before it. This is the main reason that to become a patchwork of information sourced from different
it is difficult to implement Web sites that react intelligently domains; there could even be security-related reasons to do
to user input. This shortcoming of HTTP is being addressed so.
in a number of new technologies, including ActiveX, Java, • Authentication Some pages may be protected so that only
JavaScript and cookies. HTTP is stateless: there is no link specific users can access them. Basic authentication may be
between two requests being successively carried out on the provided by HTTP, either using the WWW-Authenticate and
same connection. This immediately has the prospect of being similar headers, or by setting a specific session using HTTP
problematic for users attempting to interact with certain cookies.
pages coherently, for example, using e-commerce shopping • Proxy and tunneling Servers or clients are often located on
baskets. But while the core of HTTP itself is stateless, HTTP intranets and hide their true IP address from other computers.
cookies allow the use of stateful sessions. Using header HTTP requests then go through proxies to cross this network
extensibility, HTTP Cookies are added to the workflow, barrier. Not all proxies are HTTP proxies. The SOCKS
allowing session creation on each HTTP request to share protocol, for example, operates at a lower level. Other
the same context, or the same state. protocols, like ftp, can be handled by these proxies.
• Sessions Using HTTP cookies allows you to link requests
C. HTTP and connections
with the state of the server. This creates sessions, despite
A connection is controlled at the transport layer, and basic HTTP being a state-less protocol. This is useful not
therefore fundamentally out of scope for HTTP. Though only for e-commerce shopping baskets, but also for any site
HTTP doesn’t require the underlying transport protocol to allowing user configuration of the output.
be connection-based; only requiring it to be reliable, or not
lose messages (so at minimum presenting an error). Among V. HTTP F LOW
the two most common transport protocols on the Internet, When a client wants to communicate with a server, either
TCP is reliable and UDP isn’t. HTTP therefore relies on the the final server or an intermediate proxy, it performs the
TCP standard, which is connection-based. Before a client following steps:
and server can exchange an HTTP request/response pair, they 1. Open a TCP connection: The TCP connection is used to
must establish a TCP connection, a process which requires send a request, or several, and receive an answer. The client
several round-trips. The default behavior of HTTP/1.0 is may open a new connection, reuse an existing connection,
to open a separate TCP connection for each HTTP re- or open several TCP connections to the servers.
quest/response pair. This is less efficient than sharing a 2. Send an HTTP message: HTTP messages (before
single TCP connection when multiple requests are sent in HTTP/2) are human-readable. With HTTP/2, these simple
close succession. In order to mitigate this flaw, HTTP/1.1 messages are encapsulated in frames, making them impossi-
introduced pipelining (which proved difficult to implement) ble to read directly, but the principle remains the same. For
and persistent connections: the underlying TCP connection example:
can be partially controlled using the Connection header. • GET / HTTP/1.1
HTTP/2 went a step further by multiplexing messages over • Host: developer.mozilla.org
a single connection, helping keep the connection warm and • Accept-Language:fr
more efficient. Experiments are in progress to design a better 3.Read the response sent by the server, such as:
transport protocol more suited to HTTP. For example, Google •HTTP/1.1 200 OK
is experimenting with QUIC which builds on UDP to provide •Date: Sat, 09 Oct 2010 14:28:02 GMT
a more reliable and efficient transport protocol. •Server: Apache
•Last-Modified: Tue, 01 Dec 2009 20:18:22 GMT A. What is HTTP Response?
•ETag: "51142bc1-7449-479b075b2891b" HTTP Response is the packet of information sent by
• Accept-Ranges: bytes Server to the Client in response to an earlier Request made by
• Content-Length: 29769 Client. HTTP Response contains the information requested
• Content-Type: text/html by the Client. For example, the request to Weather Web
4.Close or reuse the connection for further requests. If Service made in the HTTP Request tutorial will contain
HTTP pipelining is activated, several requests can be sent the weather details of the location. Just like HTTP Request,
without waiting for the first response to be fully received. HTTP Response also has the same structure:
HTTP pipelining has proven difficult to implement in ex- • Status Line
isting networks, where old pieces of software coexist with • Headers, 0 or more Headers in the request
modern versions. HTTP pipelining has been superseded in • An optional Body of the Request
HTTP/2 with more robust multiplexing requests within a Response Status Line A Status Line consists of three parts:
frame 1. HTTP Protocol Version 2. Status Code 3. Reason Phrase
In the weather Rest Web Service example, lets scroll down
VI. R EQUEST OR R ESPONSE the page to see the Response section. In the response section
the first line is called the Status Line. As shown in the below
Req or response An HTTP client sends an HTTP request image:
to a server in the form of a request message which includes It is clearly visible that the Status Line has ;following
following format: information:
1)A Request-line 2) Zero or more header (Gen- • HTTP Protocol Version as (HTTP/1.1)
eral|Request|Entity) fields followed by CRLF 3) An empty • Status Code as 200
line (i.e., a line with nothing preceding the CRLF) indicating • Status Message as OK
the end of the header fields 4)Optionally a message-body B. Response Header
Just after the Status Line, Headers are displayed. Just like a
Request Header, Response Header also contains zero or more
Header lines. However, it is very uncommon to have zero
Headers in the response. Lines just after the Status Line and
before the Response Body are all Response Headers lines.
Headers are used to pass additional information to the Client.
See the image below:
In the response Header, there is a header named
Content-Type. The value of the header is application/json;
charset=utf-8. It means that server is informing the client
that the body of the response will contain a JSON formatted
data. If client needs to make any sense out of the response
body it should be interpret it as a JSON.
C. Response Body
Response Body contains the resource data that was re-
quested by the client.
VIII. HTTP MESSAGES
HTTP is based on the client-server architecture model
and a stateless request/response protocol that operates by
exchanging messages across a reliable TCP/IP connection.
An HTTP "client" is a program (Web browser or any other
client) that establishes a connection to a server for the
Fig. 1. Sequence diagram purpose of sending one or more HTTP request messages.
An HTTP "server" is a program ( generally a web server
like Apache Web Server or Internet Information Services
VII. R EQUEST-URI IIS, etc. ) that accepts connections in order to serve HTTP
requests by sending HTTP response messages. HTTP makes
The Request-URI is a Uniform Resource Identifier and use of the Uniform Resource Identifier (URI) to identify
identifies the resource upon which to apply the request. a given resource and to establish a connection. Once the
Following are the most commonly used forms to specify an connection is established, HTTP messages are passed in a
URI: Request-URI = "*" | absoluteURI | abspath | authority format similar to that used by the Internet mail [RFC5322]
and the Multipurpose Internet Mail Extensions (MIME) associated with the request or response. If entity body is
[RFC2045]. These messages include requests from client to associated, then usually Content-Type and Content-Length
server and responses from server to client which will have headers lines specify the nature of the body associated. A
the following format: message body is the one which carries the actual HTTP
HTTP-message = <Request> | <Response> ; HTTP/1.1 request data (including form data and uploaded, etc.) and
messages HTTP response data from the server ( including files, images,
HTTP requests and HTTP responses use a generic message etc.). Shown below is the simple content of a message body:
format of RFC 822 for transferring the required data. This <html>
generic message format consists of the following four items. <body>
• A Start-line <h1>Hello, World!</h1>
• Zero or more header fields followed by CRLF </body>
• An empty line (i.e., a line with nothing preceding the </html>
CRLF) • indicating the end of the header fields
• Optionally a message-body IX. S TATUS -L INE
In the following sections, we will explain each of the The first line of a Response message is the Status-Line,
entities used in an HTTP message. Message Start-Line consisting of the protocol version followed by a numeric
A start-line will have the following generic syntax: start- status code and its associated textual phrase, with each
line = Request-Line | Status-Line We will discuss Request- element separated by SP characters. No CR or LF is allowed
Line and Status-Line while discussing HTTP Request and except in the final CRLF sequence.
HTTP Response messages respectively. For now, let’s see StatusLine = HTTPVersionSPStatus CodeSPReason-
the examples of start line in case of request and response: PhraseCRLF
GET /hello.htm HTTP/1.1 (This is Request-Line sent by the
X. S TATUSCODE AND R EASONPHRASE
client)
HTTP/1.1 200 OK (This is Status-Line sent by the server) The Status-Code element is a 3-digit integer result code
of the attempt to understand and satisfy the request. These
A. Message Header codes are fully defined in section 10. The Reason-Phrase is
HTTP header fields provide required information about intended to give a short textual description of the Status-
the request or response, or about the object sent in the Code. The Status-Code is intended for use by automata and
message body. There are four types of HTTP message the Reason-Phrase is intended for the human user. The client
headers: • General-header: These header fields have general is not required to examine or display the Reason- Phrase. The
applicability for both request and response messages. • first digit of the Status-Code defines the class of response.
Request-header: These header fields have applicability only The last two digits do not have any categorization role. There
for request messages. • Response-header: These header fields are 5 values for the first digit:
have applicability only for response messages. • Entity- • 1xx: Informational - Request received, continuing pro-
header: These header fields define meta information about cess
the entity-body or, if no body is present, about the resource • 2xx: Success - The action was successfully received,
identified by the request. All the above mentioned headers understood, and accepted
follow the same generic format and each of the header field • 3xx: Redirection - Further action must be taken in order
consists of a name followed by a colon (:) and the field value to complete the request
as follows: message-header = field-name ":" [ field-value ] • 4xx: Client Error - The request contains bad syntax or
Following are the examples of various header fields: cannot be fulfilled
User-Agent:curl/7.16.3 libcurl/7.16.3 OpenSSL/0.9.7l • 5xx: Server Error - The server failed to fulfill an
zlib/1.2.3 apparently valid request
Host: www.example.com The individual values of the numeric status codes defined
Accept-Language: en, mi for HTTP/1.1, and an example set of corresponding Reason-
Date: Mon, 27 Jul 2009 12:28:53 GMT Phrase’s, are presented below. The reason phrases listed here
Server: Apache are only recommendations – they MAY be replaced by local
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT equivalents without affecting the protocol.
ETag: "34aa387-d-1568eb00" HTTP status codes are extensible. HTTP applications are
Accept-Ranges: bytes not required to understand the mean- ing of all registered
Content-Length: 51 status codes, though such understanding is obviously de-
Vary: Accept-Encoding sirable. However, applications MUST understand the class
Content-Type: text/plain of any status code, as indicated by the first digit, and
treat any unrecognized response as being equivalent to the
B. Message Body x00 status code of that class, with the exception that an
The message body part is optional for an HTTP message unrecognized response MUST NOT be cached. For example,
but if it is available, then it is used to carry the entity-body if an unrecognized status code of 431 is received by the
client, it can safely assume that there was something wrong
with its request and treat the response as if it had received a
400 status code. In such cases, user agents SHOULD present
to the user the entity returned with the response, since that
entity is likely to include human- readable information which
will explain the unusual status.
XI. REFRENCES
https://www.webopedia.com/TERM/H/HTTP.html
https://www.tutorialspoint.com/http/http messages.htm
https://www.tutorialspoint.com/http/http requests.htm
https://developer.mozilla.org/en-
US/docs/Web/HTTP/Overview

Das könnte Ihnen auch gefallen