Opened 9 years ago
Closed 9 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)
Change History (6)
Changed 9 years ago by
comment:1 Changed 9 years ago by
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.
comment:2 Changed 9 years ago by
Milestone: | tbd → 1.8 |
---|---|
Owner: | set to Bryan Forbes |
Priority: | undecided → blocker |
Status: | new → assigned |
comment:4 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
dojo/_base/xhr - Fix to support contentType