question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Header name lowercase requirement is excessive

See original GitHub issue

It was pointed out in https://code.djangoproject.com/ticket/32586 that the initial ASGI requirement that header names in responses MUST be lowercased - inherited from ASGI 1, I believe - doesn’t actually match the Django codebase, and upon inspection, this is because, unfortunately, a very small number of HTTP clients are case-sensitive to headers like Content-Type.

I believe the appropriate action is to relax the MUST requirement, and say that servers can/should try to preserve case when passed to them, but nothing requires it; this saves us from entirely flipping the expectation here. Thoughts?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
pgjonescommented, Sep 4, 2022

I’ve a request not to lowercase the incoming headers for a use case whereby Hypercorn is used as a proxy and the casing is sensitive downstream. Not lower-casing, does however cause some bugs e.g. https://github.com/pgjones/hypercorn/issues/77. I’m not sure what the least unpleasant solution is.

2reactions
andrewgodwincommented, Mar 25, 2021

Yes, this is not for incoming request headers, but for outgoing request headers. I agree that all incoming ones should be lowercased; it’s the response headers that it seems we occasionally need to keep case sensitivity.

How about this wording instead:

Response header names are case-insensitive according to the HTTP RFCs, and we encourage ASGI applications to lowercase their response headers. However, some HTTP clients are case sensitive to headers like Content-Type, and so for this reason ASGI servers should make a best-effort attempt to preserve the case of response headers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Are HTTP headers case-sensitive? - Stack Overflow
HTTP header names are case-insensitive, according to RFC 2616: 4.2: Each header field consists of a name followed by a colon (":") and...
Read more >
Capitalization | Google developer documentation style guide
If an official name begins with a lowercase letter, then put it in lowercase even at the start of a sentence. But it's...
Read more >
RFC 1035: Domain names - implementation and specification
1. Preferred name syntax The DNS specifications attempt to be as general as possible in the rules for constructing domain names. · 2....
Read more >
Preserve Header Case configuration not honored at redirect ...
You have an HTTP Request with headers that are case-sensitive (uppercase, lowercase, or a combination of them). The HTTP Request is configured ...
Read more >
Fetch Standard
Return the result of convert header names to a sorted-lowercase set with unsafeNames . A CORS non-wildcard request-header name is a header name...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found