HTTP (Hypertext Transfer Protocol)
FUNDAMENTAL OF HTTP:-
Hypertext
Transfer protocol is a request response protocol. It is an application layer in
TCP/IP protocol suite. It was originally developed to transfer files and data
in distributed, collaborative, hypermedia information system. According to this
protocol a process is run which create and store the resources like HTML image,
files etc. On request this process provides these resources and is called web
server. A web server waits for request and response when required.
-
Its main purpose is to transfer web pages from one computer (web server) to
another computer (client server).
-
It is useful to transfer web pages containing links in an environment where
there are rapid jumps among such hyperlink web pages.
-
It allows us to transfer a wide variety of data such as text, image, audio,
video or even the result of a query.
-
It is used to access virtually all types of resources on web.
WORKING OF HTTP
·
HTTP server
process is created on a port which waits for clients to make a TCP connection.
·
HTTP client
initiates a TCP connection with HTTP server.
·
HTTP server
accepts the connection.
·
Then HTTP
client sends a request for a resource to the server.
·
After
receiving the request the server process the request and perform the desired
task and sends a response back to the client.
·
HTTP server
closes the TCP connection.
·
The HTTP
client receives the response containing the information.
HTTP Message- There are two types of HTTP message.
·
Response Message-
Message sent by the server
Request Message- It
consists of following parts-
Request Line
|
Header
|
Empty Line
|
Body
(available for some message)
|
·
Request
Line- It
consists of three parts: Request type,
URL and HTTP version. These three are separated by a space.
Ø Request type-It
indicates the type of request the client want to send. It is also known as
methods. Some of the methods are following-
I.
Get-
it is specified when a client
wants retrieve a resource from server.
II.
Head- it is used when the client wants to know header
information about a resource but not the resource contain the response of the
HEAD request contains only headers request and status line but not document
content.
III.
Post-it is used when a client wants to sent some
information to the server. The commonest form of the post method is to submit
an HTML form to the server
IV.
Put-it
is used to upload a new resource or replace an existing document.
V.
Patch-this is similar to the put method except that it
specifies a list of difference that must be applied on the existing file.
VI.
Copy-
this method is used to copy a
file to one location to another
VII.
Move-it is similar to copy method except that it
deletes the source file.
VIII.
Delete-
this method is used to remove the
document from the server.
IX.
Link-this is used to create a link or links from one
document to another.
X.
Options-
it is used to retrieve the set of method supported by the server. It usually
checks whether a server is functioning properly before performing other task.
XI.
Connect-it
is used to convert a request connection into the transparent TCP/IP tunnel.
XII.
Trace-
it is used to instruct the web server to echo the request back to client.
XIII.
Unlink-
it is used to remove a link or links created by the Link method.
·
URL-this
is URL of the resource.
·
HTTP Version-this
field specifies the version of the HTTP protocol being used. It can have the
following values: HTTP/1.0 and HTTP/1.1.
RESPONSE MESSAGE- It
consists of following parts:
Status Line
|
Header
|
Empty Line
|
Body
(available for some message)
|
·
Status Line-
Status Line consists of three parts: HTTP
Version, Status code and Status phrase. These three are separated by the
space.
Ø HTTP Version: this field specifies the version of the HTTP
protocol being used. It can have the following values: HTTP/1.0 and HTTP/1.1.
Ø Status code: it is a three digit code that
indicates the status of the response. These are classified with respect to
their functionality into five groups as follow:
1.
1XX
series (informational): it represents provisional
responses. it is an informational resource. Some of its codes are-
Status code
|
Status phase
|
description
|
100
|
Continue
|
The
server receives the initial part and response back to client.
|
101
|
Switching
|
Server
switches the protocol when receive the request from client.
|
102
|
Processing
|
Server
receives the request which is currently under process.
|
2. 2XX series (Success): it represents the clients request received,
understood and accepted successfully.
Status code
|
Status phase
|
Description
|
200
|
Ok
|
This
represents the request was valid and response depends on methods used.
|
201
|
Created
|
The
request was successful and desired resource
was created.
|
202
|
Accepted
|
The
request was accepted for further processing.
|
203
|
Non-authoritative
information
|
The server is not
authoritative to information back.
|
204
|
No content
|
The body of
response has no content.
|
205
|
Reset content
|
In this client
needs to reset the document.
|
206
|
Partial content
|
Server sends
partial content in response to the header.
|
207
|
Multi-status
|
Number of response
codes depends on the number of request made.
|
3. 3XX (Redirectional): this represents the additional actions must be
taken by the client to complete the request.
Status code
|
Status phase
|
Description
|
300
|
Multiple
choices
|
Client
can follow multiple options for resource.
|
301
|
Moved
permanently
|
Resource
request no longer exists.
|
302
|
Found
|
Request
is not found currently
|
303
|
See
other
|
Method
is possibly wrong.
|
304
|
Not
modified
|
Request
resource is not modified since last request.
|
4.
4XX
Series (client error): these
codes are used to indicate the client request had an error and therefore it
cannot be fulfilled
Status code
|
Status Phrase
|
Description
|
400
|
Bad request
|
Request contains syntax
error and cannot be fulfilled.
|
401
|
Unauthorized
|
The request has
failed to be authorized.
|
403
|
Forbidden
|
Request was valid
but server is refusing to respond to it.
|
404
|
Not found
|
Request resource
was not found on the server.
|
405
|
Method not allowed
|
Method specified
the request message is not supported by the resource.
|
406
|
Not acceptable
|
Requested resource
can generate the content in the format mentioned.
|
408
|
Request time out
|
The server timed
out waiting for the request.
|
409
|
Conflict
|
The request could
not be processes due to conflict.
|
410
|
Gone
|
Requested resource
is no longer available.
|
411
|
Length required
|
The length of the
content which is required was not specified in the request message.
|
412
|
Precondition failed
|
Server fails to
follow the preconditions of the request message.
|
413
|
Request entity too
large
|
The request is too
large for the server to process.
|
414
|
Request URI to long
|
URI specify was too
long for server to process
|
415
|
Unsupported media
type
|
Server does not
support the media type specified
|
416
|
Requested range is
not satisfied
|
Server unable to
send the portion of the file is requested
|
417
|
Expectation failed
|
Server fails to
meet the values specified by the expect request header field
|
422
|
Unprocessable
entity
|
The request
contains semantic errors and cannot be fulfilled.
|
423
|
Locked
|
The request
resource is locked
|
424
|
Failed dependency
|
The request fails
due to the failure of previous request.
|
5. 5XX Series (server errors): this code represents that the server encountered
some problem and hence request cannot be satisfied at the given time.
Status code
|
Status phrase
|
Description
|
500
|
Internal
server error
|
A
message indicating that a problem has occurred in the server.
|
501
|
Not
implemented
|
The
server fails to recognize the method specified.
|
502
|
Bad
gateway
|
The
server is gateway or proxy, has received and invalid response from the
downstream server.
|
503
|
Service
unavailable
|
The
service is unavailable due to maintenance, shutting down overload.
|
504
|
Gateway
time out
|
The
server receive a timeout response from the downstream server
|
505
|
HTTP
Version not supported
|
Server
fails to support the HTTP Version specified.
|
Comments