aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Roper2013-09-17 14:24:35 +1000
committerBrian Ford2013-10-01 11:28:21 -0700
commit0d0330adc24a68cd6891a030a56d3ce3bbced03c (patch)
treed204dc986610d78b156cf043252033e6c32189cc
parent0ca5426184f6900048588f3d2c2a4a65f9abe248 (diff)
downloadangular.js-0d0330adc24a68cd6891a030a56d3ce3bbced03c.tar.bz2
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
-rw-r--r--src/ng/httpBackend.js2
-rw-r--r--test/ng/httpBackendSpec.js6
2 files changed, 7 insertions, 1 deletions
diff --git a/src/ng/httpBackend.js b/src/ng/httpBackend.js
index 37108209..99da6549 100644
--- a/src/ng/httpBackend.js
+++ b/src/ng/httpBackend.js
@@ -83,7 +83,7 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,
xhr.responseType = responseType;
}
- xhr.send(post || '');
+ xhr.send(post || null);
}
if (timeout > 0) {
diff --git a/test/ng/httpBackendSpec.js b/test/ng/httpBackendSpec.js
index f82c1750..5d2654a9 100644
--- a/test/ng/httpBackendSpec.js
+++ b/test/ng/httpBackendSpec.js
@@ -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) {