Bug 3812 - XMLHttpRequest: PUT, DELETE, HEAD and all other methods but POST actually do a GET
: XMLHttpRequest: PUT, DELETE, HEAD and all other methods but POST actually do ...
Status: RESOLVED FIXED
: WebKit
XML DOM
: 312.x
: Macintosh Mac OS X 10.3
: P2 Major
Assigned To:
:
:
:
: 7390
  Show dependency treegraph
 
Reported: 2005-07-02 05:15 PST by
Modified: 2011-02-09 08:45 PST (History)


Attachments
proposed patch (35.95 KB, patch)
2006-02-28 11:05 PST, Alexey Proskuryakov
no flags Review Patch | Details | Formatted Diff | Diff
proposed patch (36.44 KB, patch)
2006-02-28 22:29 PST, Alexey Proskuryakov
darin: review+
Review Patch | Details | Formatted Diff | Diff


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2005-07-02 05:15:32 PST
Steps to reproduce:
1) Try to do a PUT or a DELETE using XMLHttpRequest.

Actual results:
A GET request is issued.

Expected results:
Expected the full suite of HTTP verbs to be supported or at least the API to
fail detectably when a verb is not supported.

Additional information:
In order to implement a client for a clean RESTful Web service supporting full
CRUD capabilities, PUT and DELETE are needed, too.
------- Comment #1 From 2005-07-25 09:11:57 PST -------
This also applies to other verbs not explicitly defined in the HTTP spec, such
as SEARCH used in HTTP-DAV.

In my case, this prevents me from writing a client to access Microsoft Exchange
servers.
------- Comment #2 From 2005-09-04 10:22:08 PST -------
Comfirmed in ToT by source inspection; anything unknown is treated as a GET.
------- Comment #3 From 2005-12-27 14:23:24 PST -------
Would be nice to have a test case.  Although w/o server side support, that might be hard.
------- Comment #4 From 2006-01-05 06:55:35 PST -------
Writing a synthetic test shouldn't be too hard (one could take one from bug 3810 as a model), but it would 
be very helpful to have an example of a "real life" application that uses this.
------- Comment #5 From 2006-02-20 12:05:34 PST -------
*** Bug 7390 has been marked as a duplicate of this bug. ***
------- Comment #6 From 2006-02-28 11:05:45 PST -------
Created an attachment (id=6776) [details]
proposed patch

There are some differences between this implementaion and Firefox:
1) For null data, "Content-Length: 0" header is sent (isn't sent in Firefox). Looks like better behavior to me; besides, I don't think we have a choice, because this header is added by NSURLConnection.
2) HEAD is not implemented - there seems to be a crashing bug in NSURLConnection, <rdar://4460899>.
3) After #2 is fixed, we won't be sending a body in HEAD requests, just like we don't send it in GET ones. Firefox ignores the body in GET requests, but sends it in HEAD ones, which looks like a bug to me.

Also fixed a bug: send(null) was actually sending characters "null" instead of an empty body.
------- Comment #7 From 2006-02-28 22:17:38 PST -------
(From update of attachment 6776 [details])
Should use String instead of QString in new code, like the new parameter to TransferJob. String converts itself into NSString without even calling getNSString().
------- Comment #8 From 2006-02-28 22:29:03 PST -------
Created an attachment (id=6786) [details]
proposed patch

Addressed the comments.
------- Comment #9 From 2006-03-01 08:42:11 PST -------
(From update of attachment 6786 [details])
Change looks fine as is, but I have three comments:

    1) Is there a test for the change in JSXMLHttpRequest.cpp? That change looks fine, but I'd like to see a test that was broken before and fixed now.

    2) Since method is now a String you can use equalIgnoringCase rather than calling lower when comparing the method with head.

    3) I would like the client pointer to be the first parameter to TransferJob and the method the second parameter, because the client pointer sort of a "back pointer to the claler" while the rest of the parameters are the specification of what the job is to do.

The most important of these three is (1), but I think none are a big enough deal to prevent landing the patch. I'll say r=me.
------- Comment #10 From 2006-03-01 09:51:45 PST -------
(In reply to comment #9)
1) Yes, the tests call send(null) for all methods, and there were a lot of failures before I fixed this.
2) Actually, method in XMLHTTPRequest class is still a QString, I haven't changed it.
3) Done.
------- Comment #11 From 2011-02-09 04:04:43 PST -------
Committed r78043: <http://trac.webkit.org/changeset/78043>
------- Comment #12 From 2011-02-09 04:08:00 PST -------
(In reply to comment #11)
> Committed r78043: <http://trac.webkit.org/changeset/78043>

Sorry for the noise. I just mentioned this bug in a ChangeLog, it seems that webkit-patch was too smart this time.
------- Comment #13 From 2011-02-09 08:45:23 PST -------
This still remains fixed :)