Headers
HTTP headers are very important part of both request message and response message. They mainly specify the characteristics of the resource requested and the data that are provided. For example-a client may want to accept image files only in some specified format. Similarly, the server may provide additional information about the resource being sent such as the length of the message or the last modification date of the resource.
Headers are separated by an empty line from the request and the message body. it consists of a single line or multiple lines. Each line is a single header of the following form:
Header-name: Header-value
The headers may be of two types:
· HTTP Request header format- the request header consist of three parts: General header, request header and entity header.
General Header
|
Request Header
|
Entity Header
|
· HTTP Response header format- the request header consist of three parts: General header, Response header and entity header.
General Header
|
Response Header
|
Entity Header
|
Ø General Header- Http General header provide information about the message themselves instead of what content they carry. They are mainly used to specify how the message is handled and processed.
Header Name
|
Description
|
Example
|
Cache-control
|
It
shows whether the cache is used or not
|
Cache-control
:max age=10
|
Connection
|
It
specifies whether the server should close the connection or not
|
Connection:
close
|
Date
|
It
shows the date and time when the message is originated
|
Date:
Fri., 31jan 2014 08:12:31 GMT
|
Mime-version
|
MIME
version used
|
MIME
version: 1.0
|
Upgrade
|
Preferred
communication protocol
|
Upgrade:
HTTP/2.0
|
Transfer
encoding
|
Type
of transformation that has been used to transfer the message
|
Transfer-encoding:
chunked
|
Warning
|
Specifies
the status of message transfer
|
Warning:
199 Galaxy warning
|
Via
|
Intermediate
host between the messages
|
Via:
1.0 fred 1.1 source .com
|
Ø Request Header- It is only part of request message and contain the information about the client sending the request as well as data format that client expect.
Header Name
|
Description
|
Example
|
Accept-range
|
Range type of
server support
|
Accept-range: bytes
|
Age
|
Age of the resource
in the proxy
|
Age: 18
|
Public
|
List of methods
|
Public: head
|
Retry-after
|
Date after which
the requested resource will be available
|
Retry-after: 60
|
Server
|
Name and version
number of the server
|
Server:
Apache/2.040
|
Ø Entity Header- It is present in both request and response messages. It contains the information about the message body.
Header Name
|
Description
|
Example
|
Allow
|
List
of valid methods
|
Allow:
GET,HEAD,POST
|
Content-encoding
|
Type
of encoding
|
Content-encoding:
x-gzip
|
Content-language
|
Language
of the content
|
Content-language:
en
|
Content-length
|
Length
of the response body in bytes
|
Content-length:
2453
|
Content-range
|
Location
of the partial message
|
Content-range:
bytes 10-15/25-35
|
Content-type
|
MIME
type of content
|
Content-type:
text/html
|
Etag
|
An
identifier for the specific version
|
Etag:
“678060c98se84d83dd34e02d9”
|
Expires
|
Date
and time the content will modified
|
Expires:
Fri., 28 Feb. 2014 12:19:30 GMT
|
Last-modified
|
Last
modification date of request resource
|
Last-modified:
wed, 26 Feb. 2014 15:14:30 GMT
|
Comments