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:
Hendrixer 2014-01-11 15:20:54 -08:00 committed by Vojta Jina
parent 2a3586381f
commit e1cfb1957f
2 changed files with 10 additions and 4 deletions

View file

@ -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',

View file

@ -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);
})
}); });
}); });