Skip to content

Commit 7812874

Browse files
committed
fix($http): ensure that default headers are different objects
1 parent 34fee06 commit 7812874

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/ng/http.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ function $HttpProvider() {
111111
common: {
112112
'Accept': 'application/json, text/plain, */*'
113113
},
114-
post: CONTENT_TYPE_APPLICATION_JSON,
115-
put: CONTENT_TYPE_APPLICATION_JSON,
116-
patch: CONTENT_TYPE_APPLICATION_JSON
114+
post: copy(CONTENT_TYPE_APPLICATION_JSON),
115+
put: copy(CONTENT_TYPE_APPLICATION_JSON),
116+
patch: copy(CONTENT_TYPE_APPLICATION_JSON)
117117
},
118118

119119
xsrfCookieName: 'XSRF-TOKEN',

test/ng/httpSpec.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1428,9 +1428,13 @@ describe('$http', function() {
14281428

14291429
describe('defaults', function() {
14301430

1431-
it('should expose the defaults object at runtime', function() {
1432-
expect($http.defaults).toBeDefined();
1431+
it('should ensure that default headers are different objects', function(){
1432+
expect($http.defaults.headers.post).not.toBe($http.defaults.headers.put);
1433+
expect($http.defaults.headers.put).not.toBe($http.defaults.headers.patch);
1434+
expect($http.defaults.headers.patch).not.toBe($http.defaults.headers.post);
1435+
});
14331436

1437+
it('should expose the defaults object at runtime', function() {
14341438
$http.defaults.headers.common.foo = 'bar';
14351439
$httpBackend.expect('GET', '/url', undefined, function(headers) {
14361440
return headers['foo'] == 'bar';

0 commit comments

Comments
 (0)