Is the protocol name in URLs case sensitive?

2019-01-26 03:24发布

Is hTTp://foo.com the same as Http://foo.COM?

I know that hostnames are not sensitive but path names and query parts are sensitive.

4条回答
等我变得足够好
2楼-- · 2019-01-26 04:02

Well this document (for some HTML specification) says:

URLs in general are case-sensitive (with the exception of machine names). There may be URLs, or parts of URLs, where case doesn't matter, but identifying these may not be easy. Users should always consider that URLs are case-sensitive

And RFC1738 (Uniform Resource Locators (URL)) says (note, a URL has the form <scheme>:<scheme-specific-part>):

Scheme names consist of a sequence of characters. The lower case letters "a"--"z", digits, and the characters plus ("+"), period ("."), and hyphen ("-") are allowed. For resiliency, programs interpreting URLs should treat upper case letters as equivalent to lower case in scheme names (e.g., allow "HTTP" as well as "http").

So only lowercase characters are allowed, but uppercase characters are tolerated.
Btw Safari automatically converts to lowercase characters.

查看更多
在下西门庆
3楼-- · 2019-01-26 04:07

Citing RFC3986:

Although schemes are case-insensitive, the canonical form is lowercase and documents that specify schemes must do so with lowercase letters [...]

查看更多
成全新的幸福
4楼-- · 2019-01-26 04:15

The scheme is case-insensitive: http://tools.ietf.org/html/rfc3986#section-3.1

The hostname is also case-insensitive, since it's DNS.

The rest is case sensitive.

查看更多
Viruses.
5楼-- · 2019-01-26 04:18

It is not sensitive in practice but in theory only lower case is allowed.

From RFC 1738

2.1. The main parts of URLs

A full BNF description of the URL syntax is given in Section 5.

In general, URLs are written as follows:

   <scheme>:<scheme-specific-part>

A URL contains the name of the scheme being used () followed by a colon and then a string (the ) whose
interpretation depends on the scheme.

Scheme names consist of a sequence of characters. The lower case
letters "a"--"z", digits, and the characters plus ("+"), period
("."), and hyphen ("-") are allowed. For resiliency, programs
interpreting URLs should treat upper case letters as equivalent to lower case in scheme names (e.g., allow "HTTP" as well as "http").

查看更多
登录 后发表回答