mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-04 13:14:49 +00: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:
parent
0ca5426184
commit
0d0330adc2
2 changed files with 7 additions and 1 deletions
|
|
@ -83,7 +83,7 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,
|
||||||
xhr.responseType = responseType;
|
xhr.responseType = responseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
xhr.send(post || '');
|
xhr.send(post || null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,12 @@ describe('$httpBackend', function() {
|
||||||
expect(xhr.$$async).toBe(true);
|
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() {
|
it('should normalize IE\'s 1223 status code into 204', function() {
|
||||||
callback.andCallFake(function(status) {
|
callback.andCallFake(function(status) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue