This post is for advanced learners.

HTTP header and HTTP body format with examples.

Hyper Text Transfer Protocol communication allows two types of messages to be transferred between the Client and the server, HTTP Request and the HTTP Response. The request is sent by the client/browser to the server and the response is sent by the server to the browser. Both the message have a common format, they both contain a HTTP Header and a HTTP Body.
Http request/response format

HTTP Header

The HTTP Header contains information about the HTTP Body and the Request/Response.

Information about the body is related to the content of the Body such as the length of the content inside the body.

The information about Request/Response is the general information about the request/response and it is not specific to the content of the body, example at what time the Request was made or the browser used to make the request.

The properties in header are specified as name-value pair which are separated from each other by a colon ‘:’ . The format is given below.


What are the types of HTTP Headers?

In HTTP 1.1, header can further divided into 3 parts.

  1. General Header
  2. Request/Response Header
  3. Entity Header

General Header

Nothing to do with the HTTP body’s content being transferred but it contains general information about the communication such as the date and time on which the request/response was generated. This header is common to both Request and Response. Example

Date:Tue, 17 Nov 2015 16:39:15 GMT

Request/Response Headers

Request Header is present when you make a request to the server and the response header is present when the server sends a response back to the client/browser.

Request Header contains information about the request such as the URL that you have requested, the method(GET, POST, HEAD) ,the browser used to generate the request and other info. Example

User-Agent:”Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0″

The term browser is also called user-Agent. So even a simple request to a page involves sending the information about your browser and the operating system you are using. You can see from the above Header field that i am using Windows 10 and Firefox 41.0 browser.

Response Header is received by the browser from the server after the user sends a request for a particular page or resource and it contains information such as the encoding used in the content, the server software that is used on the server machine to generate the response and other information. Example


Most of the sites usually hide their server information in order to make it hard for hackers to know which software is being used on the server.

Entity headers

This header contains information about the actual message or the HTTP body that is being sent. Information such as content length, the language of the content, encoding, expiration date and other important stuff. Example


This is the content-length of the Home page of Clean Tutorials, this means that the length of the body/content (not the header) is 4595 bytes, that’s around 4.5 kilobytes of data.  Pretty small right? No, this is just the textual data, now the browser will start reading this data received and encounter all other CSS, JavaScript, Image files’s URL’s in the head section and make a separate HTTP request to fetch them and when all the requests have been sent and their response received the final length is the sum of content-length of all the responses. Phew! Beginners might find some of the terms used here hard but don’t worry it has nothing to do with future lessons.


Now comes the content/message body which is the actual data you want to fetch. The content can contain your HTML code or an image or your CSS stylesheets, JavaScript files depending on the resource for which you have made the request for.

CommentsLoad Comments