All Tutorials
What are HTTP Headers: Definition & Types
What are HTTP Headers: Definition & Types

What are HTTP Headers: Definition & Types

Learn about the 4 types of HTTP Headers and deepen your understanding with a detailed example.
Saurabh Dhingra
Founder, Uptut | Trainer & Consultant: DevOps, QA and IoT
QA
July 17, 2023
All trainings
What are HTTP Headers: Definition & Types

What are HTTP Headers: Definition & Types

Learn about the 4 types of HTTP Headers and deepen your understanding with a detailed example.

A very important part of HTTP (Hypertext Transfer Protocol) is HTTP header and it plays a crucial role in sending additional information in HTTP request or response. 

We discussed earlier that data is sent to the browser through the web server corresponding to the website. The two components, i.e server and browser manage the exchange of information related to the document through HTTP header.

What is a HTTP header?

Every HTTP request has a header area which carries information like the date of the request, the referrer and the language preference.  A similar header field is present in the HTTP response as well through which the server sends information to the browser of the user. The end user is also able to see this process of exchange of information.

These HTTP headers have one- line fields, each line carrying a pair of names or a value. This is called as key-value-pair which is separated using a colon and terminated with a line break. 

The name of the header is not case sensitive. At the end of the header, there is an empty field header. Some of the headers fields have comments while some can have quality (q) key value pairs which are separated using an equal (=) sign.

RFC (Request for Comments) is where the values which are used for HTTP header are defined. Apart from this, there could be some non-standard headers (prefixed with -X) which are useful while adding user defined information.

What are the 4 types of HTTP headers?

1. General Header

These are headers which are usually applicable to request as well as response messages.

2. Client Request Header

These are headers which are applicable just for request messages.

3. Server Response Header

These are headers which are applicable just for response messages.

4. Entity Header

These are headers which are responsible for defining meta information regarding the entity- body and in the absence of body, regarding the resource which is identified by the request.

Example of HTTP Header

The following diagram represents an HTTP Header.

Example of an HTTP Header

Difference between Accept Type and Content Type Headers

HTTP Accept header is a type of request header which carries information from the client to the server regarding the content type can be understood by the client and is expressed as MIME types. Values are set for this header by the browser and this depends on the context where the request is made. 

On the other hand, the Content type header acts like a negotiator wherein the server chooses a proposed content type and sends the information to the client through the content-type header. It is like a string describing the format of the file which is sent with the file. 

In the absence of an Accept type header in the request, it is automatically assumed by the server that all types of media are accepted by the client.

Conclusion

We learnt above that HTTP headers are a key component in sending additional information in HTTP request or response. They are mainly intended for the communication between the server and client in both directions.

The 4 types of HTTP headers are: General, Client Request, Server Response and Entity headers, each performing their own function. 

Next up in our API Testing tutorial is understanding more about Authentication and Authorisation. Let’s jump to the next article to learn.

If you’re looking to implement this knowledge in your organisation, you can follow an expert-led, personalised approach to minimise the scope of mistakes and successful execution. Explore training and consulting with Uptut.

Excited to upskill?

Learn LIVE from experts with your team. Request a free expert consultation and plan the training roadmap with Uptut.
talk to an expert
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.