mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 15:24:43 +00:00
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. Closes #5742 Closes #5747 Closes #5764
This commit is contained in:
parent
2a3586381f
commit
e1cfb1957f
2 changed files with 10 additions and 4 deletions
|
|
@ -111,9 +111,9 @@ function $HttpProvider() {
|
||||||
common: {
|
common: {
|
||||||
'Accept': 'application/json, text/plain, */*'
|
'Accept': 'application/json, text/plain, */*'
|
||||||
},
|
},
|
||||||
post: CONTENT_TYPE_APPLICATION_JSON,
|
post: copy(CONTENT_TYPE_APPLICATION_JSON),
|
||||||
put: CONTENT_TYPE_APPLICATION_JSON,
|
put: copy(CONTENT_TYPE_APPLICATION_JSON),
|
||||||
patch: CONTENT_TYPE_APPLICATION_JSON
|
patch: copy(CONTENT_TYPE_APPLICATION_JSON)
|
||||||
},
|
},
|
||||||
|
|
||||||
xsrfCookieName: 'XSRF-TOKEN',
|
xsrfCookieName: 'XSRF-TOKEN',
|
||||||
|
|
@ -324,7 +324,7 @@ function $HttpProvider() {
|
||||||
* to `push` or `unshift` a new transformation function into the transformation chain. You can
|
* 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
|
* also decide to completely override any default transformations by assigning your
|
||||||
* transformation functions to these properties directly without the array wrapper. These defaults
|
* 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.
|
* services you wish to be involved in your transformations.
|
||||||
*
|
*
|
||||||
* Similarly, to locally override the request/response transforms, augment the
|
* Similarly, to locally override the request/response transforms, augment the
|
||||||
|
|
|
||||||
|
|
@ -1439,6 +1439,12 @@ describe('$http', function() {
|
||||||
$http.get('/url');
|
$http.get('/url');
|
||||||
$httpBackend.flush();
|
$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.patch);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue