var r = new XMLHttpRequest();
r.open("GET", "nowhere.html", false);
*** Bug 14832 has been marked as a duplicate of this bug. ***
What version is this a regression from? I'm getting the same result (-1100) in shipping 10.4.10 Safari/WebKit.
Clearly, it's wrong to expose a platform-specific error code as http status, but I would expect it to be 0 or 404 in this case. Do other browsers set the status of failed file:// request to 400?
Sorry for not being clear, sometimes it is difficult to figure out how Safari has changed given how much of our own code is written on top of it.
What I meant to say is that Safari 3 beta 3.0.1 and the V3 branch up until that point throws an error for the code sample that I provided, while the latest nightlies just set the status code to -1100 on Mac and 112 on Windows.
Either throwing an error as in V3 beta or setting the status code to a consistent value in the 400s would be a fine resolution.
We no longer raise an exception in this case, because it broke some Dashboard widgets. I would really love to fix this in a sensible way, but we may have to make Windows port match Mac first, and only fix the behavior of both after Safari 3 (it seems too late to change Mac behavior now).
Other cases to verify are trying to access a local directory instead of a file, and permissions problems.
This was not a problem for me for the Safari 3.X series (i.e. the same 'failure' code was being used for both plaforms), but is now definitely a problem for the Safari 4.X developer preview. Safari/Windows is just returning a 404, whether the directory exists or not (I'm using this for 'directory existence detection').
Here is what I would propose (and which should obviously work cross-platform):
1. If the file:// URL points to a file and the file exists, the status code should return 200. The responseText/responseXML may very well be empty or null (meaning no content). If the file doesn't exist, it returns 404.
2. If the file://URL points to a directory and the directory exists (even if it has no files within it), the status code should return 200. If the directory doesn't exist, it returns 404.
I'll amend what I said earlier. It seems that this is also an issue for Safari/Windows 3.1X.
So Safari 3.1+ on Windows and Safari 4.0 developer preview all platforms are showing inconsistent and screwy values for this.