What is the purpose of the headers?

Question

In this exercise and the rest of the lesson, we passed headers along with the requests. What is the purpose of these headers?

Answer

The main purpose of the headers is to pass additional information with the request or response being sent by the client or the server.

There are several different types of headers based on their contexts:

Request headers which contain information about the fetched resource.

Response headers which contain additional information about the response.

General headers which apply to the request but with no relation to the data contained in the body.

Entity headers which contain information about the body.