Safari, XMLHttpRequest, and WebDAV
Apparently, Safari’s implementation of the XMLHttpRequest object doesn’t support HTTP methods other than GET and POST. If you try to use anything else, say SEARCH, then it’s silently converted to GET.
I guess this is supposed to protect me from doing something wrong, but really it’s just not trusting me to know what I want to do. I hate this. And it’s not as if this is a technical issue. All Safari has to do is insert the string into the HTTP request, just as it’s already doing for GET and POST. There’s no new logic to handle arbitrary methods.
Not suprisingly, smarter browsers, say Firefox, aren’t quite so inhibited.
This has put a bit of a crimp in my plan to write a calendar Dashboard widget that pulls data from Outlook using WebDAV. I can work around this, but I’m not sure if it’s worth the effort. Stupid Apple.
Comment by xbhoff on 28 May 2005:
I don’t know if it’s deliberate or just another of the many flaws that you’ll find with xmlHttpRequest as implemented in Safari 1.3/2.0. It fails to return a status code on anything but an HTTP 200 OK response, doesn’t return statusTest of any kind on anything, and getAllResponseHeaders() or getResponseHeader() don’t return anything if the response is not an HTTP 200. Then there’s the issue with senidng multiple requests to the same URL — unless you do something like set a request header for “if-modified-since” it will simply return the cached response from the first request to that URL.
It is stupid and deliberate, or is it just sloppy and untested?
Comment by Adam Trachtenberg on 28 May 2005:
Dunno about motivations. I hope that as AJAX becomes more widespread, Apple will feel the pressure to make Safari more fully compliant, or they’ll be left out of the conversation.
I had previously ran into the URL caching bug. I solved it by adding a fake query string to the end, which is hacky to say the least. Especially when it’s a local file. :)
Comment by Helge on 17 July 2005:
This is an extraordinarily annoying issue in the NSURLRequest class of Cocoa Foundation. It does not only affect Safari but all Cocoa applications which want to do something else but GET and POST.
Comment by Daniel J. Wilson on 17 July 2005:
From a quick search of the WebKit Bugzilla, it appears that Apple is aware of their incomplete implementation of XMLHttpRequest:
http://bugzilla.opendarwin.org/show_bug.cgi?id=3812
You might want to add a comment specifically about SEARCH support being absent.
Comment by Adam Trachtenberg on 25 July 2005:
Thanks for the pointer to the bug page. I added a comment and put myself on the CC list.