Skip to content
Middle5 views

We also talked about request headers. Could you name some headers you encountered most often and explain what they mean and what they're used for?

Practice

AI answer

Common HTTP headers include:

  • Content-Type — the format of the request or response body, for example application/json.
  • Accept — the response formats the client is willing to accept.
  • Authorization — authentication data, for example Bearer <token>.
  • User-Agent — information about the client sending the request.
  • Host — the hostname being accessed; important for virtual hosting.
  • Accept-Encoding — supported response compression methods, for example gzip.
  • Cookie — session data or other values stored by the client.
  • Cache-Control — caching rules.
  • Origin and Access-Control-* — participate in the CORS mechanism.
  • X-Request-ID or traceparent — identifiers used to correlate a request with logs and traces.

Headers can apply to either a request or a response; for example, Content-Type is used in both. Do not put secrets in headers that may end up in logs.