Other meanings of HTTP message header
Computer Networking
An HTTP message header is a component of an HTTP request or response that conveys metadata about the message, such as content type, caching policies, authentication credentials, and connection options. Headers are transmitted as a series of lines after the request or status line and before the message body, each following the format Name: Value. They are defined by the HTTP specification and are essential for the proper functioning of the World Wide Web, enabling clients and servers to negotiate content, manage sessions, and enforce security policies.
HTTP message headers follow a simple, line-based format. Each header field consists of a case-insensitive field name, a colon, optional whitespace, and a field value. The header section ends with an empty line, which separates it from the message body. According to RFC 9110, field names are tokens, and field values can contain a variety of characters, with some fields allowing multiple values separated by commas. The structure is designed to be extensible, allowing new headers to be defined without breaking existing implementations.
Headers are divided into four categories: general headers (apply to both requests and responses), request headers, response headers, and entity headers (now called representation headers). This classification helps in understanding the purpose and scope of each field. For example, Cache-Control is a general header, while Host is a request header and Server is a response header.
Among the most widely used headers are Host, which is mandatory in HTTP/1.1 and specifies the domain name of the server, enabling virtual hosting. Content-Type indicates the media type of the body, such as text/html or application/json, and is crucial for correct rendering. Content-Length specifies the body size in bytes, allowing the recipient to know when the message ends. Authorization carries credentials for HTTP authentication, while Cookie and Set-Cookie manage session state.
Other important headers include User-Agent, which identifies the client software, and Referer, which indicates the previous page. Accept and Accept-Encoding allow the client to express preferences for content types and compression methods. Cache-Control and ETag are central to HTTP caching, enabling efficient reuse of resources. Security-related headers like Strict-Transport-Security and Content-Security-Policy help protect against attacks.
The HTTP header concept originated in HTTP/0.9, which had no headers, and was introduced in HTTP/1.0 (RFC 1945) with a limited set. HTTP/1.1 (RFC 2616, later updated by RFC 7230-7235 and RFC 9110-9112) expanded the header set and made Host mandatory. The IANA maintains a registry of HTTP header fields, ensuring consistent naming and documentation. New headers are proposed via RFCs or through the IETF process, and some become de facto standards before formalization.
HTTP/2 and HTTP/3 introduced binary framing and compression of headers using HPACK and QPACK, respectively, to reduce overhead. Despite these changes, the semantics of headers remain largely unchanged, ensuring backward compatibility. The standardization process continues to address emerging needs, such as privacy (e.g., Global Privacy Control) and performance (e.g., Priority).
Beyond the common headers, there are numerous niche and experimental fields. For instance, Forwarded standardizes the X-Forwarded-For header for passing client IP information through proxies. Alt-Svc allows servers to advertise alternative services, such as HTTP/3 over UDP. Early-Data indicates that a request was sent in TLS 1.3 early data, which has security implications. Digest provides a checksum of the message body for integrity verification.
Some headers are intentionally non-standard but widely used, like X-Requested-With for AJAX requests. The Upgrade header enables protocol switching, such as from HTTP to WebSocket. Additionally, headers can be used for tracking, as with DNT (Do Not Track), though its adoption has been inconsistent. The Large-Allocation header was proposed to help browsers optimize memory for large pages. These examples illustrate the breadth and adaptability of HTTP headers.
This article focuses on the HTTP message header as defined in the HTTP specifications.
Help improve the encyclopedia. Reports go straight to the site manager.