Capitalization of Content-* headers

php.internals

Unnamed Person

4 years ago
Hello, A while ago I observed that PHP's capitalization of Content-Type and Content-Length headers is Content-type and Content-length. This is working fine, but is inconsistent with the rest of the headers which are printed in Header-Name format. I have proposed changing that [1] and concerns were raised about potential breakages that could happen. However, the HTTP standard (RFC 2616 - "Hypertext Transfer Protocol -- HTTP/1.1", section 4.2 "Message Headers") says that the headers should be parsed as case-insensitive so any eventual breakages could be considered as non-adherences to the standard and it might be a good chance to fix them. What do you think about this change? With best regards, Vedran Miletić [1] https://github.com/php/php-src/pull/7577 [2] https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
-- Vedran Miletić vedran.miletic.net

Tim Düsterhus

4 years ago
Hi Vedran, On 3/17/22 19:03, Vedran Miletić via internals wrote:
> What do you think about this change? >
*If* a change is made I'd rather like to see all-lowercase headers, as that's the casing enforced by HTTP/2 [1] [2]. I don't see a benefit in changing one capitalized version to different capitalized version. Even though headers are defined to be case-insensitive there are consumers that (wrongly) rely on a specific casing and thus it as a matter of fact it will be a breaking change to them (even if they are wrong). Best regards Tim Düsterhus [1] https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2 [2] In the (PHP) code I'm maintaining I'm defining any new header in full lowercase.