Junior
What types of headers do you know?
sobes.tech AI
Answer from AI
HTTP headers are divided into four main categories:
- General Headers: Can be present in both requests and responses, not related to the content of the message. Examples:
Cache-Control,Connection,Date. - Request Headers: Contain more information about the resource the client wants to obtain or about the client itself. Examples:
Accept,Authorization,User-Agent. - Response Headers: Contain additional information about the server or resource in the response. Examples:
Server,Set-Cookie,Allow. - Entity Headers: Describe the entity body of the message. Can be present in requests (POST or PUT) and responses. Examples:
Content-Length,Content-Type,Expires.
There are also specialized types of headers:
- CORS Headers: Manage access to resources from other domains. Examples:
Access-Control-Allow-Origin. - Proxy Headers: Used by proxy servers. Examples:
X-Forwarded-For. - Custom Headers: Non-standard headers starting with
X-, although this practice is deprecated.
Example of headers in an HTTP request:
GET /index.html HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Example of headers in an HTTP response:
HTTP/1.1 200 OK
Date: Mon, 18 Apr 2022 12:00:00 GMT
Server: Apache/2.4.41 (Ubuntu)
Last-Modified: Mon, 18 Apr 2022 11:50:00 GMT
ETag: "5cb27f11-b26"
Content-Length: 2854
Content-Type: text/html