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:
James Roper 2013-09-17 14:24:35 +10:00 committed by Brian Ford
parent 0ca5426184
commit 0d0330adc2
2 changed files with 7 additions and 1 deletions

View file

@ -83,7 +83,7 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,
xhr.responseType = responseType;
}
xhr.send(post || '');
xhr.send(post || null);
}
if (timeout > 0) {

View file

@ -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) {