Opened 7 years ago

Closed 7 years ago

#15591 closed defect (fixed)

[patch][cla] dojo/_base/xhr does not respect contentType in __XhrArgs

Reported by: kbenjamin Owned by: Bryan Forbes
Priority: blocker Milestone: 1.8
Component: Core Version: 1.8.0b1
Keywords: Cc:
Blocked By: Blocking:

Description

The contentType arg is not implemented the same way in dojo/request/xhr and no accommodation was made for that in dojo/_base/xhr which now calls dojo/request/xhr.

The result is that the Content-Type header is set to defaults, not the specified value.

Impacted modules: dojo/rpc/JsonService, various dojox/*, probably lots of stuff in the wild.

The fix is simple. In dojo/_base/xhr::dojo.xhr(): Insert at line 611 (just after the block dealing with args.headers):

		if(typeof args.contentType !== 'undefined'){
			if(typeof options.headers == 'undefined'){
				options.headers = {};
			}
			options.headers['Content-Type'] = args.contentType;
		}

A patched version of dojo/_base/xhr is attached.

Attachments (2)

xhr.js (24.4 KB) - added by kbenjamin 7 years ago.
dojo/_base/xhr - Fix to support contentType
xhr.patch (571 bytes) - added by kbenjamin 7 years ago.
diff from github master

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by kbenjamin

Attachment: xhr.js added

dojo/_base/xhr - Fix to support contentType

comment:1 Changed 7 years ago by kbenjamin

In further research, I've found that there are no tests that directly call xhr() and, therefore, none that test setting contentType, which is one reason this regression was not discovered.

I realize that with dojo/_base/xhr deprecated that such a test might be a waste of time but considering the potential impact of this regression, I'm not so sure.

The tests for dojo/rpc also do not surface the regression as they do not check Content-Type headers in resources/test_JsonRPCMediator.php.

I'll attempt to create a diff file to upload per Kitson's suggestion.

Changed 7 years ago by kbenjamin

Attachment: xhr.patch added

diff from github master

comment:2 Changed 7 years ago by dylan

Milestone: tbd1.8
Owner: set to Bryan Forbes
Priority: undecidedblocker
Status: newassigned

comment:3 Changed 7 years ago by Bryan Forbes

In [29261]:

Fix for contentType property to dojo.xhr*. refs #15591 !strict

comment:4 Changed 7 years ago by Bryan Forbes

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.