Why does RFC 3986 (URI generic syntax) declare the "host" component to be case-insensitive when the syntax rules show it to be case-sensitive?

24 views Asked by At

First, a reminder to future self (the figure RFC 3986, Section 3. Syntax Components complemented with Section 3.2. Authority):

   The following are two example URIs and their component parts:

                 userinfo       host     port
                    |            |         |
                ____|______   ___|_____   _|
               /           \ /         \ /  \ 
         foo://user:[email protected]:8042/over/there?name=ferret#nose
         \_/   \____________________________/\_________/ \_________/ \__/
          |           |                          |            |        |
       scheme     authority        *----------- path        query   fragment
          |                        |
          |   _____________________|__
         / \ /                        \
         urn:example:animal:ferret:nose

Section 3.2.2. Host makes it clear on multiple occasions that the "host" part is case-insensitive,

The host subcomponent is case-insensitive. [..] Although host is case-insensitive, producers and normalizers should use lowercase for registered names and hexadecimal addresses for the sake of uniformity, while only using uppercase letters for percent-encodings.

but the syntax rules allow for upper-case letters as well:

host        = IP-literal / IPv4address / reg-name
reg-name    = *( unreserved / pct-encoded / sub-delims )
unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"

See Section 2.3. Unreserved Characters.


Is the reasoning behind this related to the robustness principle? The "scheme" URI component (section 3.1. Scheme) seems to be defined with the same ambiguity, but it does justify it:

Although schemes are case-insensitive, the canonical form is lowercase and documents that specify schemes must do so with lowercase letters. An implementation should accept uppercase letters as equivalent to lowercase in scheme names (e.g., allow "HTTP" as well as "http") for the sake of robustness but should only produce lowercase scheme names for consistency.

    scheme      = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )

Section 3.2.2. Host does not state this rationale explicitly, so I presume that it is implied then?

1

There are 1 answers

0
toraritte On

As Moshi pointed out, I conflated the concepts of "case-sensitivity" and "case of letters":

The "scheme" component and the "host" authority sub-component being case-insensitive means that they can contain letters of any cases, but an implementation should treat "scheme" and "host" values, respectively, as identical if they only differ in the cases of the letters contained. (See ALPHA's definition in Section 1.3 Syntax Notation.)


For future reference (summing up this answer):