HTTP header fields are a list of linefeed-separated HTTP data being sent and received by both the client program and server on every HTTP request. These headers are usually invisible to the end-user and are only visible to the backend programs and people maintaining the internet system. They define how information sent/received through the connection are encoded (as in Accept-Encoding), the session verification and identification of the client (as in browser cookies, IP address, user-agent) or their anonymity thereof (VPN or proxy masking, user-agent spoofing), how the server should handle data (as in Do-Not-Track), the age of the document being downloaded, amongst others.
General format
The header fields are transmitted after the request line (in case of a request HTTP message) or the response line (in case of a response HTTP message), which is the first line of a message. Header fields are colon-separated key-value pairs in clear-text string format, terminated by a carriage return (CR) and line feed (LF) character sequence. The end of the header section is indicated by an empty field line, resulting in the transmission of two consecutive CR-LF pairs. In the past, long lines could be folded into multiple lines; continuation lines are indicated by the presence of a space (SP) or horizontal tab (HT) as the first character on the next line. This folding is now deprecated.
Field names
A core set of fields is standardized by the Internet Engineering Task Force (IETF) in RFCs 7230, 7231, 7232, 7233, 7234, and 7235. The permanent registry of header fields and repository of provisional registrations are maintained by the IANA. Additional field names and permissible values may be defined by each application.
Header field names are case-insensitive. This is in contrast to HTTP method names (GET, POST, etc.), which are case-sensitive.
HTTP/2 makes some restrictions on specific header fields (see below).
Non-standard header fields were conventionally marked by prefixing the field name with X- but this convention was deprecated in June 2012 because of the inconveniences it caused when non-standard fields became standard. An earlier restriction on use of Downgraded was lifted in March 2013.
Field values
A few fields can contain comments (i.e. in User-Agent, Server, Via fields), which can be ignored by software.
Many field values may contain a quality (q) key-value pair separated by equals sign, specifying a weight to use in content negotiation. For example, a browser may indicate that it accepts information in German or English, with German as preferred by setting the q value for de higher than that of en, as follows:
Accept-Language: de; q=1.0, en; q=0.5
Size limits
The standard imposes no limits to the size of each header field name or value, or to the number of fields. However, most servers, clients, and proxy software impose some limits for practical and security reasons. For example, the Apache 2.3 server by default limits the size of each field to 8,190 bytes, and there can be at most 100 header fields in a single request.
Standard request fields
Name | Description | Example | Status | Standard |
---|---|---|---|---|
A-IM | Acceptable instance-manipulations for the request. | A-IM: feed |
Permanent | RFC 3229 |
Accept | Media type(s) that is/are acceptable for the response. See Content negotiation. | Accept: text/html |
Permanent | RFC 2616, 7231 |
Accept-Charset | Character sets that are acceptable. | Accept-Charset: utf-8 |
Permanent | RFC 2616 |
Accept-Datetime | Acceptable version in time. | Accept-Datetime: Thu, 31 May 2007 20:35:00 GMT |
Provisional | RFC 7089 |
Accept-Encoding | List of acceptable encodings. See HTTP compression. | Accept-Encoding: gzip, deflate |
Permanent | RFC 2616, 7231 |
Accept-Language | List of acceptable human languages for response. See Content negotiation. | Accept-Language: en-US |
Permanent | RFC 2616, 7231 |
Access-Control-Request-Method, Access-Control-Request-Headers |
Initiates a request for cross-origin resource sharing with Origin (below). | Access-Control-Request-Method: GET |
Permanent: standard | |
Authorization | Authentication credentials for HTTP authentication. | Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== |
Permanent | |
Cache-Control | Used to specify directives that must be obeyed by all caching mechanisms along the request-response chain. | Cache-Control: no-cache |
Permanent | |
Connection | Control options for the current connection and list of hop-by-hop request fields.Must not be used with HTTP/2. | Connection: keep-alive Connection: Upgrade |
Permanent | |
Content-Encoding | The type of encoding used on the data. See HTTP compression. | Content-Encoding: gzip |
Permanent | |
Content-Length | The length of the request body in octets (8-bit bytes). | Content-Length: 348 |
Permanent | |
Content-MD5 | A Base64-encoded binary MD5 sum of the content of the request body. | Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ== |
Obsolete | |
Content-Type | The Media type of the body of the request (used with POST and PUT requests). | Content-Type: application/x-www-form-urlencoded |
Permanent | |
Cookie | An HTTP cookie previously sent by the server with Set-Cookie (below). | Cookie: $Version=1; Skin=new; |
Permanent: standard | |
Date | The date and time at which the message was originated (in “HTTP-date” format as defined by RFC 7231 Date/Time Formats). | Date: Tue, 15 Nov 1994 08:12:31 GMT |
Permanent | |
Expect | Indicates that particular server behaviors are required by the client. | Expect: 100-continue |
Permanent | |
Forwarded | Disclose original information of a client connecting to a web server through an HTTP proxy. | Forwarded: for=192.0.2.60;proto=http;by=203.0.113.43 Forwarded: for=192.0.2.43, for=198.51.100.17 |
Permanent | |
From | The email address of the user making the request. | From: user@example.com |
Permanent | |
Host | The domain name of the server (for virtual hosting), and the TCP port number on which the server is listening. The port number may be omitted if the port is the standard port for the service requested.Mandatory since HTTP/1.1. If the request is generated directly in HTTP/2, it should not be used. | Host: en.wikipedia.org:8080 Host: en.wikipedia.org |
Permanent | |
HTTP2-Settings | A request that upgrades from HTTP/1.1 to HTTP/2 MUST include exactly one HTTP2-Setting header field. The HTTP2-Settings header field is a connection-specific header field that includes parameters that govern the HTTP/2 connection, provided in anticipation of the server accepting the request to upgrade. |
HTTP2-Settings: token64 |
Permanent: standard | |
If-Match | Only perform the action if the client supplied entity matches the same entity on the server. This is mainly for methods like PUT to only update a resource if it has not been modified since the user last updated it. | If-Match: "737060cd8c284d8af7ad3082f209582d" |
Permanent | |
If-Modified-Since | Allows a 304 Not Modified to be returned if content is unchanged. | If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT |
Permanent | |
If-None-Match | Allows a 304 Not Modified to be returned if content is unchanged, see HTTP ETag. | If-None-Match: "737060cd8c284d8af7ad3082f209582d" |
Permanent | |
If-Range | If the entity is unchanged, send me the part(s) that I am missing; otherwise, send me the entire new entity. | If-Range: "737060cd8c284d8af7ad3082f209582d" |
Permanent | |
If-Unmodified-Since | Only send the response if the entity has not been modified since a specific time. | If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT |
Permanent | |
Max-Forwards | Limit the number of times the message can be forwarded through proxies or gateways. | Max-Forwards: 10 |
Permanent | |
Origin | Initiates a request for cross-origin resource sharing (asks server for Access-Control-* response fields). | Origin: http://www.example-social-network.com |
Permanent: standard | |
Pragma | Implementation-specific fields that may have various effects anywhere along the request-response chain. | Pragma: no-cache |
Permanent | |
Prefer | Allows client to request that certain behaviors be employed by a server while processing a request. | Prefer: return=representation |
Permanent | RFC 7240 |
Proxy-Authorization | Authorization credentials for connecting to a proxy. | Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== |
Permanent | |
Range | Request only part of an entity. Bytes are numbered from 0. See Byte serving. | Range: bytes=500-999 |
Permanent | |
Referer | This is the address of the previous web page from which a link to the currently requested page was followed. (The word “referrer” has been misspelled in the RFC as well as in most implementations to the point that it has become standard usage and is considered correct terminology) | Referer: http://en.wikipedia.org/wiki/Main_Page |
Permanent | |
TE | The transfer encodings the user agent is willing to accept: the same values as for the response header field Transfer-Encoding can be used, plus the “trailers” value (related to the “chunked” transfer method) to notify the server it expects to receive additional fields in the trailer after the last, zero-sized, chunk.Only trailers is supported in HTTP/2. |
TE: trailers, deflate |
Permanent | |
Trailer | The Trailer general field value indicates that the given set of header fields is present in the trailer of a message encoded with chunked transfer coding. | Trailer: Max-Forwards |
Permanent | |
Transfer-Encoding | The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.Must not be used with HTTP/2. | Transfer-Encoding: chunked |
Permanent | |
User-Agent | The user agent string of the user agent. | User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/12.0 |
Permanent | |
Upgrade | Ask the server to upgrade to another protocol.Must not be used in HTTP/2. | Upgrade: h2c, HTTPS/1.3, IRC/6.9, RTA/x11, websocket |
Permanent | |
Via | Informs the server of proxies through which the request was sent. | Via: 1.0 fred, 1.1 example.com (Apache/1.1) |
Permanent | |
Warning | A general warning about possible problems with the entity body. | Warning: 199 Miscellaneous warning |
Permanent |
Source: List of HTTP header fields, https://en.wikipedia.org/wiki/List_of_HTTP_header_fields [Retrieved November 18, 2021]