jetty.project
jetty.project copied to clipboard
Review case of MimeType.Type charsets
Jetty version(s) 12
Description
We generate charsets in lower case (e.g. text/html;charset=iso-8859-1
), but when parsed by HttpParser, they end up as uppercase: text/html;charset=ISO-8859-1
We should be consistent with our cases
Go with all lowercase. (this should apply to mime-types too)
From https://datatracker.ietf.org/doc/html/rfc9110#section-8.3.1
For example, the following media types are equivalent in describing
HTML text data encoded in the UTF-8 character encoding scheme, but
the first is preferred for consistency (the "charset" parameter value
is defined as being case-insensitive in [RFC2046], Section 4.1.2):
text/html;charset=utf-8
Text/HTML;Charset="utf-8"
text/html; charset="utf-8"
text/html;charset=UTF-8
@joakime I think this is another whatwg inspired cluster-stuffup:
- The java
StandardCharsets
are all uppercase in both the constant name and theirString
names. - The IANA registry uses uppercase
- RFC8187 Encoding for HTTP Header Field Parameters explicitly uses "UTF-8" in its ABNF
- WhatWG refers to the encodings by their uppercase names, but then recommends that they be generated in lowercase ?!?!?
So again, rather than enforce standards, the whatwg again just normalises those that cannot follow simple specifications, and expects the world to follow!
But as you say, RFC9110 recommends we prefer lowercase, so I guess we follow!