HTTP header
AnHTTP header is a field of an HTTP request or response that passes additional context and metadata about the request or response. For example, a request message can use headers to indicate its preferred media formats, while a response can use header to indicate the media format of the returned body. Headers are case-insensitive, begin at the start of a line and are immediately followed by a':' and a header-dependent value. The value finishes at the next CRLF or at the end of the message.
The HTTP and Fetch specifications refer to a number of header categories, including:
- Request header: Headers containing more information about the resource to be fetched or about the client itself.
- Response header: Headers with additional information about the response, like its location or about the server itself (name, version, …).
- Representation header: metadata about the resource in the message body (e.g., encoding, media type, etc.).
- Fetch metadata request header: Headers with metadata about the resource in the message body (e.g., encoding, media type, etc.).
A basic request with one header:
http
GET /example.html HTTP/1.1Host: example.comRedirects have mandatory headers (Location):
http
HTTP/1.1 302 FoundLocation: /NewPage.htmlA typical set of headers:
http
HTTP/1.1 304 Not ModifiedAccess-Control-Allow-Origin: *Age: 2318192Cache-Control: public, max-age=315360000Connection: keep-aliveDate: Mon, 18 Jul 2016 16:06:00 GMTServer: ApacheVary: Accept-EncodingVia: 1.1 3dc30c7222755f86e824b93feb8b5b8c.cloudfront.net (CloudFront)X-Amz-Cf-Id: TOl0FEm6uI4fgLdrKJx0Vao5hpkKGZULYN2TWD2gAWLtr7vlNjTvZw==X-Backend-Server: developer6.webapp.scl3.mozilla.comX-Cache: Hit from cloudfrontX-Cache-Info: cachedNote:Older versions of the specification referred to:
- General header: Headers applying to both requests and responses but with no relation to the data eventually transmitted in the body.
- Entity header: Headers containing more information about the body of the entity, like its content length or its MIME-type (this is a superset of what are now referred to as the Representation metadata headers)
In this article
See also
- List of all HTTP headers
- Syntax ofheaders in the HTTP specification
- Related glossary terms: