Header fields provide required information about requests or responses, or about objects sent in the notification body. There are four types of Headers in HTTP messages:
General-Header : These Header fields have general application capabilities for both request and response notifications.
Request Type (Request-Header) : These Header fields are only applicable to required notifications.
Response Type (Response-Header) : These Header fields are only applicable for response messages.
Entity-Header : These fields define the body-entity information or, if no body is present, about the source identified by the request.
All Headers are mentioned above in a general format and each Header field includes a name followed by a colon (:) and the field value as follows:
message-header = field-name ":" [field-value]
Below is an example of the various Header fields:
User-Agent: curl / 7.16.3 libcurl / 7.16.3 OpenSSL / 0.9.7l zlib / 1.2.3
Host: www.example.com
Accept-Language: en, mi
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT
ETag: "34aa387-d-1568eb00"
Accept-Ranges: bytes
Content-Length: 51
Vary: Accept-Encoding
Content-Type: text / plain
The message body is optional for an HTTP message but if it is available, then it is used to carry the body associated with the request or response. If the entity body is linked, then usually Content-Type and Content-Length lines determine the nature of the linked body.
A notification body is the part that carries the actual HTTP request data (including sample data and uploaded, etc.) and HTTP response data from the Server (including files, images, etc.). Below is the simple content of a notification body:
Hello, World!
In the next two chapters we will discuss how to use the concepts explained to prepare HTTP Requests and HTTP Responses.
According to Tutorialspoint
Previous post: Parameters in HTTP
Next lesson: Request (Request) in HTTP