mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-01 12:33:37 +08:00
fix($httpBackend): don't send empty string bodies
The `XMLHttpRequest.send` spec defines different semantics for `null` than for an empty String: an empty String should be sent with a `Content-Type` of `text/plain`, whereas `null` should have no `Content-Type` header set. Closes #2149
This commit is contained in:
@@ -83,7 +83,7 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,
|
||||
xhr.responseType = responseType;
|
||||
}
|
||||
|
||||
xhr.send(post || '');
|
||||
xhr.send(post || null);
|
||||
}
|
||||
|
||||
if (timeout > 0) {
|
||||
|
||||
@@ -68,6 +68,12 @@ describe('$httpBackend', function() {
|
||||
expect(xhr.$$async).toBe(true);
|
||||
});
|
||||
|
||||
it('should pass null to send if no body is set', function() {
|
||||
$backend('GET', '/some-url', null, noop);
|
||||
xhr = MockXhr.$$lastInstance;
|
||||
|
||||
expect(xhr.$$data).toBe(null);
|
||||
});
|
||||
|
||||
it('should normalize IE\'s 1223 status code into 204', function() {
|
||||
callback.andCallFake(function(status) {
|
||||
|
||||
Reference in New Issue
Block a user