Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The "//" in "http://"

Tags:

uri

protocols

I would like to know why designers of the URI standard chose to have // in the definition of URIs like http://.

Why make it so complex? Why not just use http:?

like image 547
Vincent Cantin Avatar asked Apr 01 '12 21:04

Vincent Cantin


2 Answers

Here's the answer (The Web’s Inventor Regrets One Small Thing).

In hindsight Tim Berners-Lee would remove it as well.

The reason it was included:

The double slash, though a programming convention at the time, turned out to not be really necessary.

like image 159
Simeon Visser Avatar answered Feb 19 '23 22:02

Simeon Visser


RFC 2396 covers this, FWIW.

http://www.ietf.org/rfc/rfc2396.txt

The pseudocode in part 7 of section 5.2 in particular best answers your question, that the "//" is there to denote that what follows it is the authority part of the URI (since the pseudocode also makes it clear that it's not a required part of the URI).

if authority is defined then
         append "//" to result
         append authority to result

In addition, it's spelled out a bit more in RFC 3986 section 3.

When authority is not present, the path cannot begin with two slash characters ("//"). These restrictions result in five different ABNF rules for a path (Section 3.3), only one of which will match any given URI reference.

like image 37
James Manning Avatar answered Feb 19 '23 21:02

James Manning