Key takeaways:
- Header names are case-insensitive, but the rules for header values depend on the specific field.
- HTTP/2 and HTTP/3 require lowercase header names, which makes header compression more efficient.
- Reading headers with exact string matches often causes bugs if developers forget to normalize the text first.
Whether HTTP headers are case-sensitive depends on the part of the header you examine. Web standards state that header names are always case-insensitive. In HTTP/1.1, a server will process a request just fine even with mixed capitalization.
The field value after the colon is often case-sensitive, but it depends on how that header is defined. HTTP/1.1 allows mixed-case names, but HTTP/2 and HTTP/3 require lowercase names, which also makes their header compression more efficient.
Are HTTP header names case sensitive?
The current standard in RFC 9110 states that clients and servers must treat header names, such as Content-Length, as case-insensitive. If you configure an application to send Content-Type, content-type, or CONTENT-TYPE, the receiving server will process all three as the same field.
It also applies to custom HTTP headers, so any unique fields you create for internal APIs are normalized just like standard headers. Most HTTP libraries and frameworks handle incoming request headers for you, either by storing the names in one consistent case or by matching them case-insensitively.
Are HTTP header values case sensitive?
Once you look past the colon at the field value, case sensitivity depends on the standard for that specific header. A web server might ignore capitalization for a Cache-Control directive, but it will reject an authentication token if a single letter has the wrong case.
If you send an improperly capitalized string inside a case-sensitive field, the receiving system won’t match it. A changed token fails authentication, an altered cookie value loses the session, and a changed ETag makes the server resend the full response instead of a 304 Not Modified.
Content-Type
Case-insensitive
Systems treat text/html and TEXT/HTML as the same media type, but some parameter values, like a multipart boundary, are case-sensitive
Cache-Control
Case-insensitive
Directives like no-cache match regardless of capitalization
Authorization
Case-sensitive
Tokens rely on exact character matches to prove identity, though the scheme name, like Bearer, ignores case
Cookie
Case-sensitive
Session identifiers fail if you alter their original capitalization
ETag
Case-sensitive
Cache validation tokens require strict exact string comparisons
HTTP header case sensitivity in HTTP/1.1, HTTP/2, and HTTP/3
While HTTP/1.1 transmits header names exactly as typed, newer versions, namely HTTP/2 and HTTP/3, require lowercase names. Their standards, RFC 9113 and RFC 9114, treat a message with an uppercase header name as malformed.
The lowercase rule exists for efficiency and interoperability. With one fixed case, the header compression formats HPACK (HTTP/2) and QPACK (HTTP/3) can reuse the entries in their built-in tables, which list common names such as content-type in lowercase.
HTTP/1.1
Transmits text exactly as formatted by the client
HTTP/2
Requires lowercase names, so clients convert them before transmission
HTTP/3
Requires lowercase names, so clients convert them before transmission
Common issues with HTTP header capitalization
The most common bug is comparing header names as case-sensitive strings. In Node.js, for example, incoming header names are stored in lowercase, so req.headers['Content-Type'] returns undefined, while req.headers['content-type'] returns the value. Code that matches raw header lines against Content-Type fails the same way when a response arrives over HTTP/2.
A second problem appears when code or a proxy rule normalizes more than the header name. Lowercasing a whole header line also changes its value, so a Bearer token or API key no longer matches, and the request fails authentication, usually with a 401 Unauthorized response. Normalize names only and pass values through unchanged.
Duplicate headers cause the third type of issue. Accept and accept are the same field, so a recipient may merge both lines into one comma-separated value, as RFC 9110 allows. Code that stores headers in a plain dictionary keyed by the exact name keeps them as two separate fields instead. Set-Cookie is the exception, since its lines can’t be combined.
HTTP libraries prevent most of these problems for you. Python’s requests library, for example, stores response headers in a case-insensitive dictionary, so both lookups below return the same value:
import requests
response = requests.get('https://marsproxies.com')
print(response.headers['Content-Type'])
print(response.headers['content-type'])
Both lines print the same value (for example, text/html; charset=utf-8), because the lookup ignores the case of the key.
Other HTTP libraries solve the same problem in their own way. Go’s net/http stores names in a canonical form such as Content-Type, and the Fetch API’s Headers object matches names case-insensitively. Use these built-in lookups instead of comparing header names yourself.
Does header capitalization matter when using proxies?
When traffic passes through a proxy, the intermediary server often inspects and modifies the data before forwarding it. Many proxies normalize this traffic by rewriting header names into strict lowercase or standard title case. HAProxy, for example, sends all header names in lowercase, regardless of the HTTP version.
HTTPS works differently. When you request an HTTPS page through a forward proxy, your client opens a tunnel with the CONNECT method, so the proxy only relays encrypted data and can’t read, add, or change the headers inside it.
Keep in mind, however, that reverse proxies or CDNs that terminate your TLS connection can still normalize your headers before sending them to the backend server.
If you build web scrapers or troubleshoot networks, remember this behavior: on plain HTTP or behind a TLS-terminating proxy, the casing you see may differ from the casing that was sent, so compare both request and response headers case-insensitively.
Build web scrapers that handle HTTP headers right
Start scrapingConclusion
To build reliable web applications, remember that header names are case-insensitive, while the case sensitivity of header values depends on the specific field: Cache-Control directives ignore case, but tokens, cookies, and ETags don’t.
Although newer protocols like HTTP/2 and HTTP/3 require lowercase header names, modern client libraries handle this conversion automatically.
As long as your code compares header names case-insensitively and passes values through unchanged, your software will interact smoothly with modern web infrastructure.
FAQ
Is the Content-Type header case-sensitive?
No. Both the header name and the media type field value (like text/html) are case-insensitive.
Is the Authorization header case-sensitive?
The header name and the authorization scheme are case-insensitive, but the credentials that follow it, such as a Bearer token, are strictly case-sensitive.
Why are HTTP header names sometimes converted to lowercase?
HTTP/2 and HTTP/3 require lowercase header names, so clients convert them before sending. Some libraries, such as Node.js, also lowercase every incoming header name, even over HTTP/1.1.
Are custom HTTP headers case-sensitive?
No. Custom header names are case-insensitive and follow the exact same normalization rules as standard headers. Whether their values are case-sensitive is up to the application that defines them.
Are HTTP methods case-sensitive?
Yes. Unlike header names, HTTP methods like GET and POST are strictly case-sensitive. By convention, standardized methods are written in uppercase.