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.

Discussion: Capitalize the header names of outgoing headers.

See original GitHub issue

Although, as per RFC 2616, All the HTTP/1.1 headers should be case-insensitive. However, as a general practice, most of the major web servers have their headers capitalized. Also, some broken HTTP/1.1 implementations do not recognize some specific headers(e.g.: Server header for Apache Benchmark) if they are not properly capitalized. It would be better if the header can be capitalized.

Performance Concerns: Compared to str.lower(), str.title() is slower. However, this can be migrated by adding an LRU Cache into the header capitalization process to solve the problem.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:34 (21 by maintainers)

github_iconTop GitHub Comments

6reactions
Lukasacommented, Feb 19, 2017

I strongly recommend making it possible to emit headers with any capitalisation, while making the current behaviour the default.

The reality is that HTTP implementations that require title cased headers are wrong. Their inability to tolerate them, forcing other implementations to psychically tolerate their preferences, is a bad behaviour and should be punished. However, it should clearly be possible to overrule that behaviour if needed to make an application work.

Note that the “capitalise as a matter of course” servers and clients are on the way out. HTTP/2 forcibly lowercases header names, which means a lot of these bad implementations get fixed as they get support for HTTP/2. So this may be a problem that reduces in scope over time.

A final note: RFC 2616 is dead. Long live RFCs 723[0-3]!

3reactions
njsmithcommented, Jan 15, 2020

Preserving the raw headers on incoming messages is tricky. I hear you on case being nice to have in debug output, but on the other hand… preserving non-meaningful case is also the root cause of all these bugs where people accidentally write case-sensitive programs.

One thing I’ve wondered is whether we should explicitly save the raw headers separately as a dedicated debugging feature (e.g. as a raw byte string, so you can see all the whitespace, header case, etc.). There’s also some discussion in https://github.com/python-hyper/h11/issues/92 of doing more normalization of header values, which would be another case where separate debug output might be useful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Capitalise the header/field names to UPPERCASE and...
Solved: Hi All, I am taking an input from an excel file where the header/field names are as below Function / Function ID...
Read more >
Are HTTP headers case-sensitive?
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 >
Letters in request headers' key are lowercase or uppercase ...
The second pic shows that headers' key are all in lowercase. These mixed keys make the same header store different field in elasticsearch....
Read more >
Headers are getting convert into lower case? | Layer7 API ...
Hello Folks,. I am facing issue when client is sending Headers in CAPITAL letters, those headers are being converted into lower by API ......
Read more >
Solved: Power Query (M) - if column header contains specif...
First step I did was to Capitalize all column headers, thanks to this query ... "key" (this will always be at the end...
Read more >

github_iconTop Related Medium Post

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