Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($http): ensure that default headers are different objects #5764

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ng/http.js
Original file line number Diff line number Diff line change
@@ -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',
8 changes: 6 additions & 2 deletions test/ng/httpSpec.js
Original file line number Diff line number Diff line change
@@ -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';