HTTP
The
Hypertext Transfer Protocol (HTTP) is a protocol used mainly to access data on
the World Wide Web. HTTP functions as a combination of FTP and SMTP. It is
similar to FTP because it transfers files and uses the services of TCP.
However, it is much simpler than FTP because it uses only one TCP connection.
There is no separate control connection; only data are transferred between the
client and the server. HTTP is like SMTP because the data transferred between
the client and the server look like SMTP messages. In addition, the format of
the messages is controlled by MIME-like headers. Unlike SMTP, the HTTP messages
are not destined to be read by humans; they are read and interpreted by the
HTTP server and HTTP client (browser). SMTP messages are stored and forwarded,
but HTTP messages are delivered immediately. The commands from the client to
the server are embedded in a request message. The contents of the requested
file or other information are embedded in a response message. HTTP uses the
services of TCP on well-known port 80.
1. HTTP Transaction
Although
HTTP uses the services of TCP, HTTP itself is a stateless protocol. The client
initializes the transaction by sending a request message. The server replies by
sending a response.
Messages
The
formats of the request and response messages are similar. A request message
consists of a request line, a header, and sometimes a body. A response message
consists of a status line, a header, and sometimes a body. Request and Status
Lines The first line in a request message is called a request line; the first
line in the response message is called the status line.
Request type: This field is used in the request
message. In version1.1of HTTP, severalrequest types are defined.
Version: The most current version of HTTP
is 1.1.
Status code: This field is used in the
response message. The status code field is similar tothose in the FTP and the
SMTP protocols. It consists of three digits.
Status phrase: This field is used in the
response message. It explains the status code intext form.
Header: The header exchanges additional
information between the client and the server.For example, the client can
request that the document be sent in a special format, or the server can send
extra information about the document. The header can consist of one or more
header lines. Each header line has a header name, a colon, a space, and a
header value.
Body: The body can be present in a
request or response message. Usually, it contains thedocument to be sent or
received.
2. Persistent Versus
Nonpersistent Connection
HTTP
prior to version 1.1 specified a nonpersistent connection, while a persistent
connection is the default in version 1.1.
Nonpersistent
Connection
In a
nonpersistent connection, one TCP connection is made for each request/response.
The following lists the steps in this strategy:
1. The
client opens a TCP connection and sends a request.
2. The
server sends the response and closes the connection.
3. The
client reads the data until it encounters an end-of-file marker; it then closes
the connection.
Persistent
Connection
HTTP version
1.1 specifies a persistent connection by default. In a persistent connection,
the server leaves the connection open for more requests after sending a
response. The server can close the connection at the request of a client or if
a time-out has been reached. The sender usually sends the length of the data
with each response. However, there are some occasions when the sender does not
know the length of the data. This is the case when a document is created
dynamically or actively.
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.