develooper Front page | perl.fwp | Postings from April 2003

Re: Resolving unterminated URL paths

From:
Abigail
Date:
April 11, 2003 01:39
Subject:
Re: Resolving unterminated URL paths
Message ID:
20030410150418.GA5652@abigail.nl
On Thu, Apr 10, 2003 at 02:02:26PM +0100, Rob Dixon wrote:
> Hi all.
> 
> Can somebody suggest how I might resolve the following?
> 
> If I make a GET request to a server with a URL like
> 
>     http::/ww.domain.com/path/path/name
> 
> how can I determine whether what is passed back is actually
> this path (i.e. 'name' is a resource) or if what I am getting is
> really
> 
>     http::/ww.domain.com/path/path/name/default.htm
> 
> or the equivalent?


Most servers will in their default configuration not give the same
response for requests to "http://ww.domain.com/path/path/name" and
"http://ww.domain.com/path/path/name/default.htm". For the former,
a 402 or 403 response code (Moved) will be given, with the location
"http://ww.domain.com/path/path/name/".



From the POV of URLs, "http://ww.domain.com/path/path/name/" and
"http://ww.domain.com/path/path/name/default.htm" are different,
even if they server the same content. There is a very important
thing to remember:

    URLs do *NOT* map to files.

I repeat,

    URLs do *NOT* map to files.

Now, your server might decide that a request for
"http://ww.domain.com/path/path/name/" gets the some content
as a request for "http://ww.domain.com/path/path/name/default.htm",
but that's server policy, and has nothing to do with URLs.

> The reason I ask is that this clearly has a bearing on relative
> links within the data returned. Are they relative to
> 
>     http::/ww.domain.com/path/path/name/
> or to
>     http::/ww.domain.com/path/path/


If you do a request for "http://ww.domain.com/path/path/name/",
a relative URL is relative to "http://ww.domain.com/path/path/name/".
If you do a request for "http://ww.domain.com/path/path/", a relative
URL is relative to "http://ww.domain.com/path/path/".

It so happens that URLs relative to
"http://ww.domain.com/path/path/name/default.htm" map to the same
absolute URLs as URLs relative to
"http://ww.domain.com/path/path/name/gagaga", URLs relative to
"http://ww.domain.com/path/path/name/fnurd", and also URLs relative to
"http://ww.domain.com/path/path/name/". This is because the final
component, whether the empty string or not, play no role in resolving
relative URLs.



Abigail



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About