W3C home > Mailing lists > Public > ietf-http-wg-old@w3.org > January to April 2001

about relative URLs

From: Dave Kristol <dmk@bell-labs.com>
Date: Tue, 13 Mar 2001 13:50:37 -0500
Message-ID: <3AAE6BFD.4E13FC6F@bell-labs.com>
To: HTTP Working Group <http-wg@hplb.hpl.hp.com>
Is the following a valid relative HTTP URL?
	http:/mypath/index.html

The intended meaning is to GET the resource "/mypath/index.html" from the
current server (the one from which the page with this link was retrieved).

There has been some discussion regarding Mozilla
(<http://bugzilla.mozilla.org/show_bug.cgi?id=34648>), which gets confused by
this URL.  (That is, it doesn't do what I intended.)  RFC 1808 (Relative URLs)
accepts them syntactically, then gives "an example algorithm" that would reject
them (sect. 4):
=======
   Step 2: Both the base and embedded URLs are parsed into their
           component parts as described in Section 2.4.

           a) If the embedded URL is entirely empty, it inherits the
              entire base URL (i.e., is set equal to the base URL)
              and we are done.

>>         b) If the embedded URL starts with a scheme name, it is
              interpreted as an absolute URL and we are done.

           c) Otherwise, the embedded URL inherits the scheme of
              the base URL.
=======

RFC 2396, Sect. 5, implies that the example is not relative, via the negation of
"A relative reference that does not begin with a scheme name or a slash
character is termed a relative-path reference."  Section 5.2 more explicitly
says (like RFC 1808):
=======
   3) If the scheme component is defined, indicating that the reference
      starts with a scheme name, then the reference is interpreted as an
      absolute URI and we are done.  Otherwise, the reference URI's
      scheme is inherited from the base URI's scheme component.
=======

I guess I haven't been paying attention.  I have been using URLs like the
example for years, and they have been accepted (by liberal programs?). 
Furthermore, I don't see why the RFC so specifically declares all URLs with a
scheme to be absolute (except that Sect. 4 says "[t]he syntax for relative URI
is a shortened form of that for absolute URI, where some prefix of the URI is
missing...".  It seems to me that an otherwise relative URL with an explicit
scheme can be parsed unambiguously.

Dave Kristol
Received on Tuesday, 13 March 2001 18:53:29 EST

This archive was generated by hypermail pre-2.1.9 : Wednesday, 24 September 2003 06:33:41 EDT