Closed Bug 1119235 Opened 9 years ago Closed 9 years ago

Http.jsm should be passing null to xhr.send if there is no postData, not an empty string

Categories

(Toolkit :: General, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38

People

(Reporter: mkaply, Assigned: mkaply)

Details

Attachments

(1 file)

I was attempting to use Http.jsm to execute a DELETE function on a server, but it was not working correctly.

The reason is because Http.jsm passes "" when there is no postData, and the server sees this as content (and a content type is passed).

Http.jsm should be passing null when there is no postData.
Attached patch 1119235.diffSplinter Review
Use null instead of empty string when there is no post data.

Also, don't call isArray unnecessarily if there is no post data.

I considered updating the log message as well, but that seemed overkill.
Attachment #8546193 - Flags: review?(dtownsend)
Attachment #8546193 - Flags: review?(dtownsend) → review+
Patrick:

Wanted to make sure you saw this since I think this is your file?
(In reply to Mike Kaply [:mkaply] from comment #2)
> Wanted to make sure you saw this since I think this is your file?

Thanks. This looks like the right change...otherwise to send no postdata you'd have to define it and set it to null...which is weird.

I CCed Florian who wrote this code originally though.
> Thanks. This looks like the right change...otherwise to send no postdata you'd have to define it and set it to null...which is weird.

Actually, that won't work either because since postData isn't defined, you still end up with the "". I tried that :)
Looks like the docs at [1] are just wrong then. Maybe we can add a test for this? :)

[1] https://dxr.mozilla.org/mozilla-central/source/toolkit/modules/Http.jsm?from=Http.jsm#21
https://hg.mozilla.org/mozilla-central/rev/f143f852ede1
Assignee: nobody → mozilla
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: