Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#16532 closed defect (fixed)

[patch][cla] dojo/request/xhr default overrides specified content-type header

Reported by: Brandon Payton Owned by: Bryan Forbes
Priority: undecided Milestone: 1.8.4
Component: IO Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:

Description

The default Content-Type in dojo/request/xhr overrides a specified content-type header when the letter casing isn't exactly "Content-Type".

The following sends the default Content-Type 'application/x-www-form-urlencoded' instead of 'application/json':

xhr.post("http://some/url", {
    headers: {
        "content-type": "application/json"
    },
    data: "[]"
})

I have attached patches for a fix and an additional unit test. The unit test required an additional PHP file for dojo/tests/request/, and that is attached as well.

Any feedback is appreciated.

Attachments (3)

dojo-request-xhr.patch (660 bytes) - added by Brandon Payton 7 years ago.
The patch for dojo/request/xhr.js
dojo-tests-request-xhr.patch (1.7 KB) - added by Brandon Payton 7 years ago.
The patch for dojo/tests/request/xhr.html
xhrEchoContentTypeHeader.php (304 bytes) - added by Brandon Payton 7 years ago.
An additional supporting .php file to be placed in dojo/tests/request/

Download all attachments as: .zip

Change History (11)

Changed 7 years ago by Brandon Payton

Attachment: dojo-request-xhr.patch added

The patch for dojo/request/xhr.js

Changed 7 years ago by Brandon Payton

The patch for dojo/tests/request/xhr.html

Changed 7 years ago by Brandon Payton

An additional supporting .php file to be placed in dojo/tests/request/

comment:1 Changed 7 years ago by Brandon Payton

This work is covered by my personal CLA.

comment:2 Changed 7 years ago by Brandon Payton

I just realized this patch doesn't add the default Content-Type into response.options.headers. That seems desirable. Let me know what you think, and I can provide another patch and test case to verify the default content-type shows up in response.options.

comment:3 Changed 7 years ago by bill

Component: GeneralIO
Owner: set to Bryan Forbes

comment:4 Changed 7 years ago by dylan

Milestone: tbd1.9

Bryan,

Please review for consideration as part of 1.9.

comment:5 Changed 7 years ago by Bryan Forbes

In [30738]:

Fix content-type casing issues. !strict refs #16532

comment:6 Changed 7 years ago by Bryan Forbes

In [30739]:

Fix content-type casing issues (1.8 backport). !strict refs #16532

comment:7 Changed 7 years ago by Bryan Forbes

Resolution: fixed
Status: newclosed

comment:8 Changed 7 years ago by bill

Milestone: 1.91.8.4
Note: See TracTickets for help on using tickets.