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

$http.defaults.headers post and put fields is one object #5742

Closed
cevek opened this issue Jan 11, 2014 · 2 comments
Closed

$http.defaults.headers post and put fields is one object #5742

cevek opened this issue Jan 11, 2014 · 2 comments

Comments

@cevek
Copy link

cevek commented Jan 11, 2014

console.log($http.defaults.headers.post == $http.defaults.headers.put) // true
@IgorMinar
Copy link
Contributor

wow. how is it possible that nobody noticed this until now. crazy!

@IgorMinar
Copy link
Contributor

would you or someone else like to create a PR? it's should be a trivial change.

just replace:

headers: {
      common: {
        'Accept': 'application/json, text/plain, */*'
      },
      post:   CONTENT_TYPE_APPLICATION_JSON,
      put:    CONTENT_TYPE_APPLICATION_JSON,
      patch:  CONTENT_TYPE_APPLICATION_JSON
    }

with:

headers: {
      common: {
        'Accept': 'application/json, text/plain, */*'
      },
      post:   copy(CONTENT_TYPE_APPLICATION_JSON),
      put:    copy(CONTENT_TYPE_APPLICATION_JSON),
      patch:  copy(CONTENT_TYPE_APPLICATION_JSON)
    }

AND write a test for this. something like:

expect($http.defaults.headers.post).not.toBe($http.defaults.headers.put);
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);

Hendrixer added a commit to Hendrixer/angular.js that referenced this issue Jan 11, 2014
Hendrixer added a commit to Hendrixer/angular.js that referenced this issue Jan 13, 2014
send PUT and POST through copy() to make sure they are not the same.
Include unit test.

Closes angular#5742
Hendrixer added a commit to Hendrixer/angular.js that referenced this issue Jan 13, 2014
send PUT and POST through copy() to make sure they are not the same.
Include unit test.

Closes angular#5742
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this issue Jan 27, 2014
Send PUT and POST through copy() to make sure they are not the same.

Closes angular#5742
Closes angular#5747
Closes angular#5764
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this issue Jan 27, 2014
Send PUT and POST through copy() to make sure they are not the same.

Closes angular#5742
Closes angular#5747
Closes angular#5764
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants