feross / simple-get

Simplest way to make http get requests. Supports HTTPS, redirects, gzip/deflate, streams in < 100 lines
MIT License
401 stars 50 forks source link

Do not modify opts.headers #34

Closed finnp closed 7 years ago

finnp commented 7 years ago

Hey,

I was getting some socket hang up errors in my code. Because I reused the headers object that I passed to simple-get.

const headers = {...}
get({headers: headers, method: 'POST', url: 'http...', body: '.....'}, function () {
  // the next request fails, because it has a content-length that it shouldn't have
   get({headers: headers, method: 'GET', url: 'http... '})
})

This PR makes a copy of opts.headers to make sure that the original it will not be modified.

finnp commented 7 years ago

@bendrucker Thanks. Weirdly enough, the test still fails on travis.

feross commented 7 years ago

I think your repo is really out-of-date (probably because you sent a PR in the past and haven't pulled recently?).

We actually stopped using the xtend dep and just use Object.assign now. I'm surprised the GitHub diff doesn't show more changes...

feross commented 7 years ago

I fixed this in https://github.com/feross/simple-get/commit/c2e7345efc1e03dab6f341a81f9add04556f7881 and released as 2.7.0.

finnp commented 7 years ago

Ah yeah I forgot to pull the latest master. Thanks!