From 189673f7a7549a4326155bcbd84652aba0bb0f42 Mon Sep 17 00:00:00 2001 From: Hendrixer Date: Sat, 11 Jan 2014 15:20:54 -0800 Subject: [PATCH 1/3] fix headers common, tests pass: closes #5742 --- src/ng/http.js | 8 ++++---- test/ng/httpSpec.js | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ng/http.js b/src/ng/http.js index 231e683e2b1e..4ca89e4fd3d1 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', @@ -324,7 +324,7 @@ function $HttpProvider() { * to `push` or `unshift` a new transformation function into the transformation chain. You can * also decide to completely override any default transformations by assigning your * transformation functions to these properties directly without the array wrapper. These defaults - * are again available on the $http factory at run-time, which may be useful if you have run-time + * are again available on the $http factory at run-time, which may be useful if you have run-time * services you wish to be involved in your transformations. * * Similarly, to locally override the request/response transforms, augment the diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index d3653a67ee7d..dcff3f461952 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -1430,6 +1430,12 @@ describe('$http', function() { it('should expose the defaults object at runtime', function() { expect($http.defaults).toBeDefined(); + expect($http.defaults.headers.post).not.toBe($http.defaults.headers.put); + expect($http.defaults.headers.post).not.toBe($http.defaults.headers.patch); + expect($http.defaults.headers.put).not.toBe($http.defaults.headers.patch); + expect($http.defaults.headers.put).not.toBe($http.defaults.headers.post); + expect($http.defaults.headers.patch).not.toBe($http.defaults.headers.put); + expect($http.defaults.headers.patch).not.toBe($http.defaults.headers.post); $http.defaults.headers.common.foo = 'bar'; $httpBackend.expect('GET', '/url', undefined, function(headers) { From 71a1256319b98ab9f567a048e80a93d6f081f663 Mon Sep 17 00:00:00 2001 From: Hendrixer Date: Sun, 12 Jan 2014 23:13:32 -0800 Subject: [PATCH 2/3] fix($http): ensure default headers PUT and POST are different objects send PUT and POST through copy() to make sure they are not the same. Include unit test. Closes #5742 --- test/ng/httpSpec.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index dcff3f461952..ab3e4c39b768 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -1430,12 +1430,6 @@ describe('$http', function() { it('should expose the defaults object at runtime', function() { expect($http.defaults).toBeDefined(); - expect($http.defaults.headers.post).not.toBe($http.defaults.headers.put); - expect($http.defaults.headers.post).not.toBe($http.defaults.headers.patch); - expect($http.defaults.headers.put).not.toBe($http.defaults.headers.patch); - expect($http.defaults.headers.put).not.toBe($http.defaults.headers.post); - expect($http.defaults.headers.patch).not.toBe($http.defaults.headers.put); - expect($http.defaults.headers.patch).not.toBe($http.defaults.headers.post); $http.defaults.headers.common.foo = 'bar'; $httpBackend.expect('GET', '/url', undefined, function(headers) { @@ -1445,6 +1439,13 @@ describe('$http', function() { $http.get('/url'); $httpBackend.flush(); }); + + it('should have seperate opbjects for defaults PUT and POST', function() { + expect($http.defaults.headers.post).not.toBe($http.defaults.headers.put); + expect($http.defaults.headers.post).not.toBe($http.defaults.headers.patch); + expect($http.defaults.headers.put).not.toBe($http.defaults.headers.post); + expect($http.defaults.headers.put).not.toBe($http.defaults.headers.patch); + }) }); }); From 32ed7bb2e6e04800ffe18493751bb19ca593df51 Mon Sep 17 00:00:00 2001 From: Hendrixer Date: Sun, 12 Jan 2014 23:18:11 -0800 Subject: [PATCH 3/3] fix($http): ensure default headers PUT and POST are different objects send PUT and POST through copy() to make sure they are not the same. Include unit test. Closes #5742 --- test/ng/httpSpec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index ab3e4c39b768..a0417d9ad99c 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -1443,7 +1443,6 @@ describe('$http', function() { it('should have seperate opbjects for defaults PUT and POST', function() { expect($http.defaults.headers.post).not.toBe($http.defaults.headers.put); expect($http.defaults.headers.post).not.toBe($http.defaults.headers.patch); - expect($http.defaults.headers.put).not.toBe($http.defaults.headers.post); expect($http.defaults.headers.put).not.toBe($http.defaults.headers.patch); }) });