Randy Webb wrote:
> Thomas 'PointedEars' Lahn said the following on 1/27/2006 8:22 PM:
>> McKirahan wrote:
>>> "Jake Barnes" [...] wrote [...]
>>>> checkUrlValidity("www/monkeyclaus.org");
>>>>
>>>> the script returns a 404 error, even thought that is a legit address.
>>> "www/" prefix is not a "legit address".
>>>
>>> Don't you mean www.monkeyclaus.org?
>> This is not a "legit address" (read: a URI) either. The way he uses
>> XMLHttpRequest, it has to be at least "http://www.monkeyclaus.org";
>> everything else is hoping for the UA to correct it and is error-prone.
>
> It is not "error-prone", it is an error. Any URL given to an HTTPRequest
> Object has to be a full URL, not a partial. And that includes the
> Protocol.
We are both wrong. What you say is not specified anywhere, in fact the
IXMLHttpRequest reference specifies that even relative URIs are allowed:
<URL:http://msdn.microsoft.com/library/en-us/xmlsdk/html/52aaf5ff-e302-4490-821a-cb3a085fe5ee.asp>
This is supported by the source code of nsIXHTMLHttpRequest which is the
Gecko DOM implementation of that interface.
<URL:http://lxr.mozilla.org/seamonkey/source/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp#991>
Besides, we are talking about XML_HTTP_ requests. It is perfectly
reasonable for a UA to prefix any URI reference without the scheme-part
with `http://' (and the resolved relative path-part).
>> I would use "http://www.monkeyclaus.org/" to avoid implicit server-side
>> redirection.
>
> That is bad advice.
Not at all.
> If the server uses server-side redirection then the script needs the
> return from the redirected page, not the URL itself as that would be
> useless to you.
Nonsense, server-side redirection works transparent to the XMLHttpRequest
object.
However, if the trailing slash indicating the index document is omitted,
most Web servers (including all Apache HTTP servers not explicitly
configured otherwise) redirect to the URL with the trailing slash (per a
301 [Moved Permanently] response) if there is no matching resource, and
include both requests in their logs. This takes longer and increases
network and server load compared to including the slash in the request
in the first place, and is therefore not to be recommended. Example:
<URL:http://web-sniffer.net/?url=http%3A%2F%2Fwww.microsoft.com%2Fie&submit=Submit&http=1.0&gzip=yes&type=HEAD&ua=Mozilla%2F5.0+%28X11%3B+U%3B+Linux+i686%3B+en-US%3B+rv%3A1.8%29+Gecko%2F20060110+Debian%2F1.5.dfsg-4+Firefox%2F1.5+Mnenhy%2F0.7.3.0+Web-Sniffer%2F1.0.23>
(or use `HEAD -UsSe http://www.microsoft.com/ie`)
However, I was wrong in assuming that the former also applies to the index
document of the document root -- which is obvious to me now as the first
parameter of the HTTP request command (OPTIONS|HEAD|GET|POST|PUT|DELETE
TRACE|CONNECT) must include a _non-empty_ URI reference [or a `*']); the
UA will have to "append the /" in order to issue the request. So both
URIs are equal in _this_ case, indeed.
<URL:http://web-sniffer.net/?url=http%3A%2F%2Fwww.microsoft.com&submit=Submit&http=1.0&gzip=yes&type=HEAD&ua=Mozilla%2F5.0+%28X11%3B+U%3B+Linux+i686%3B+en-US%3B+rv%3A1.8%29+Gecko%2F20060110+Debian%2F1.5.dfsg-4+Firefox%2F1.5+Mnenhy%2F0.7.3.0+Web-Sniffer%2F1.0.23>
<URL:http://web-sniffer.net/?url=http%3A%2F%2Fwww.microsoft.com%2F&submit=Submit&http=1.0&gzip=yes&type=HEAD&ua=Mozilla%2F5.0+%28X11%3B+U%3B+Linux+i686%3B+en-US%3B+rv%3A1.8%29+Gecko%2F20060110+Debian%2F1.5.dfsg-4+Firefox%2F1.5+Mnenhy%2F0.7.3.0+Web-Sniffer%2F1.0.23>
<URL:http://web-sniffer.net/?url=http%3A%2F%2Fwww.monkeyclaus.org&submit=Submit&http=1.0&gzip=yes&type=HEAD&ua=Mozilla%2F5.0+%28X11%3B+U%3B+Linux+i686%3B+en-US%3B+rv%3A1.8%29+Gecko%2F20060110+Debian%2F1.5.dfsg-4+Firefox%2F1.5+Mnenhy%2F0.7.3.0+Web-Sniffer%2F1.0.23>
<URL:http://web-sniffer.net/?url=http%3A%2F%2Fwww.monkeyclaus.org%2F&submit=Submit&http=1.0&gzip=yes&type=HEAD&ua=Mozilla%2F5.0+%28X11%3B+U%3B+Linux+i686%3B+en-US%3B+rv%3A1.8%29+Gecko%2F20060110+Debian%2F1.5.dfsg-4+Firefox%2F1.5+Mnenhy%2F0.7.3.0+Web-Sniffer%2F1.0.23>
PointedEars
Received on Tue Feb 7 21:25:30 2006