cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: libcurl's treatment of `file:' and absolute paths

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sat, 4 Aug 2001 16:28:59 +0200 (MET DST)

On Sat, 14 Jul 2001, Stefan Ulrich wrote:

> A question on the `file:' access scheme: Currently libcurl
> extracts from a URL like
> file://localhost/path/to/file
> the following path component:
> path/to/file

> Since the leading '/' is removed from the path, fetching this file fails
> on my Linux system.

The first slash after the host name is not a part of the path, it is a mere
separator.

I think this quote from RFC1738 says it pretty clearly:

        The rest of the locator consists of data specific to the
        scheme, and is known as the "url-path". It supplies the
        details of how the specified resource can be accessed. Note
        that the "/" between the host (or port) and the url-path is
        NOT part of the url-path.

(section 3.1, page 5)

> I must admit that from reading RFCs 1738 and 2396, I couldn't tell
> for sure whether the above URL is correct or whether it should be
> file://localhost//path/to/file

Both are valid URLs, but the latter example is an absolute path while the
first one is a relative path.

> instead. OTOH, the form with one `/' following the `localhost' is rather
> common (as a quick search on Google for `file://localhost/' shows), and
> it is supported by most browsers and also by W3C's libwww. So maybe
> libcurl should support it as well?

Well, libcurl supports file://localhost/foo as well, but that makes 'foo' a
relative path from where libcurl is used.

How does libwww treat the path in 'file://localhost/foo' ? as '/foo' ?

-- 
     Daniel Stenberg -- curl dude -- http://curl.haxx.se/
Received on 2001-08-04