Closed Bug 123499 Opened 23 years ago Closed 23 years ago

XMLHttpRequest only supports HTTP GET, POST

Categories

(Core :: XML, defect, P2)

defect

Tracking

()

VERIFIED FIXED
mozilla0.9.9

People

(Reporter: matthew, Assigned: hjtoi-bugzilla)

Details

Attachments

(1 file)

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US) Gecko/20011221
BuildID:    2001122106

The XMLHttpRequest object only supports HTTP GET and POST. If an HTTP DELETE
request is constructed, it is transformed into a POST.

Reproducible: Always
Steps to Reproduce:
Run a script such as the following:

var xmlhttpdelete = new XMLHttpRequest();
xmlhttpdelete.open ("DELETE", "http://localhost");
var deletestr =
Components.classes["@mozilla.org/supports-wstring;1"].createInstance(Components.interfaces.nsISupportsWString);
deletestr.data = '';
xmlhttpdelete.send(deletestr);


Actual Results:  Web server access log shows a POST request being made.

Expected Results:  DELETE request should have been made.

It appears that the request method is correct until the call to SetUploadStream,
which changes it to POST.

http://lxr.mozilla.org/seamonkey/source/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp#1043
Attached patch Proposed patchSplinter Review
I don't really know what HTTP commands we support, and is this a safe way to do
this, or if there is a preferred way. Adding darin to Cc. Darin, if you think
this is ok, just slap sr, otherwise it would be great if you could educate us ;)
Comment on attachment 67879 [details] [diff] [review]
Proposed patch

sr=darin... looks good to me.
Attachment #67879 - Flags: superreview+
Comment on attachment 67879 [details] [diff] [review]
Proposed patch

Ok, in that case it is also r=heikki.

Do you want me to check this in for you?
Attachment #67879 - Flags: review+
Yes please.
Checked in. I also fixed the comments in the IDL file to just give GET and POST
as examples, not the only supported commands.
Status: NEW → RESOLVED
Closed: 23 years ago
OS: Windows NT → All
Priority: -- → P2
Hardware: PC → All
Resolution: --- → FIXED
Target Milestone: --- → mozilla0.9.9
QA Contact: petersen → rakeshmishra
Verified fixed on the trunk build 2002-12-17-08-trunk on win2K , using the
following test case : 

<html>
<body>
<script>
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var xmlhttpdelete = new XMLHttpRequest();
//xmlhttpdelete.open ("DELETE", "http://localhost");
xmlhttpdelete.open ("DELETE", "http://www.google.com");
//var deletestr
=Components.classes["@mozilla.org/supports-wstring;1"].createInstance(Components.interfaces.nsISupportsWString);
//deletestr.data = ' ';
//xmlhttpdelete.send(deletestr);
xmlhttpdelete.send(' ');
</script>
</body>
</html>

Response data:
0[235f68]: http request [
0[235f68]:   DELETE / HTTP/1.1
0[235f68]:   Host: www.google.com
0[235f68]:   User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;
rv:1.3b) Gecko/20021217 Netscape/7.0+
0[235f68]:   Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=
0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1


marking verified
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: