diff --git a/src/ng/http.js b/src/ng/http.js index 231e683e2b1e..1d0122206db1 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -111,9 +111,9 @@ function $HttpProvider() { common: { 'Accept': 'application/json, text/plain, */*' }, - post: CONTENT_TYPE_APPLICATION_JSON, - put: CONTENT_TYPE_APPLICATION_JSON, - patch: CONTENT_TYPE_APPLICATION_JSON + post: copy(CONTENT_TYPE_APPLICATION_JSON), + put: copy(CONTENT_TYPE_APPLICATION_JSON), + patch: copy(CONTENT_TYPE_APPLICATION_JSON) }, xsrfCookieName: 'XSRF-TOKEN', diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index d3653a67ee7d..0c1a1ac28868 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -1428,9 +1428,13 @@ describe('$http', function() { describe('defaults', function() { - it('should expose the defaults object at runtime', function() { - expect($http.defaults).toBeDefined(); + it('should ensure that default headers are different objects', function(){ + expect($http.defaults.headers.post).not.toBe($http.defaults.headers.put); + expect($http.defaults.headers.put).not.toBe($http.defaults.headers.patch); + expect($http.defaults.headers.patch).not.toBe($http.defaults.headers.post); + }); + it('should expose the defaults object at runtime', function() { $http.defaults.headers.common.foo = 'bar'; $httpBackend.expect('GET', '/url', undefined, function(headers) { return headers['foo'] == 'bar';