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

RESOLVED FIXED in mozilla38

Status

()

RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: mkaply, Assigned: mkaply)

Tracking

Trunk
mozilla38
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

4 years ago
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.
(Assignee)

Comment 1

4 years ago
Created attachment 8546193 [details] [diff] [review]
1119235.diff

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+
(Assignee)

Comment 2

4 years ago
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.
(Assignee)

Comment 4

4 years ago
> 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
Last Resolved: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
You need to log in before you can comment on or make changes to this bug.