The Most Important HTTP Request Headers

When a browser requests a resource from a server, it uses HTTP. This request includes a set of key-value pairs giving informations like the version of the browser or what file format it understands. There key-value pairs are called request headers.

The server answers with the requested resource but also sends response headers giving information on the resource or the server itself.

Below are the most important request headers:

  1. Host: The domain. The only required header.
Host: website-name.com
  1. User-Agent: Name + version of your browser and OS.
User-Agent: curl/7.64.1
  1. Referer: Website that linked or included the resource.
Referer: https://website-name.com
  1. Authorization: A password or API token
Authorization: Basic xyz(base64 encoded user: password)
  1. Cookie: Send cookies the server sent earlier and keeps you logged in.
Cookie: user=john
  1. Range: Let’s you continue downloads (“get bytes 100-200”)
Range: bytes=100-200
  1. Cache-Control: “max-age=60” means cached responses must be less than 60 seconds old.

  2. If-Modified-since: Only send if resource was modified after this time.

If-Modified-Since: Sun, 21 Sep...
  1. If-None-Match: Only sent if the ETag doesn’t match those listed.
If-None-Match: "z9843ca"
  1. Accept: MIME type you want the response to be.
Accept: image/png
  1. Accept-Encoding: Set this to “gzip” and you’ll probably get a compressed response.
Accept-Encoding: gzip
  1. Accept-Language: Set this to “fr-CA” and you might get a response in French.
Accept-Language: fr-CA
  1. Content-Type: MIME type of request body, e.g. “application/json”

  2. Content-Encoding: Will be “gzip” if the request body is gzipped.

  3. Connection: “close” of “keep-alive” Whether to keep the TCP connection open.