* fix: premature close with chunked transfer encoding and for async iterators in Node 12
This PR backports the fix from #1064 to the `2.x.x` branch following
the [comment here](https://github.com/node-fetch/node-fetch/pull/1064#issuecomment-849167400).
I had to add some extra babel config to allow using the `for await..of`
syntax in the tests. The config is only needed for the tests as
this syntax is not used in the implementation.
* chore: fix up tests for node 6+
* chore: codecov dropped support for node < 8 without shipping major
* chore: npm7 strips empty dependencies hash during install
* chore: pin deps to versions that work on node 4
* chore: do not emit close error after aborting a request
* chore: test on node 4-16
* chore: simplify chunked transer encoding bad ending
* chore: avoid calling .destroy as it is not in every node.js release
* chore: listen for response close as socket is reused and shows warnings
* Update readme and changelog for `options.agent`
- Fix content-length issue introduced in v2.5.0
* More test coverage for `extractContentType`
* Slightly improve test performance
* `Response.url` should not return null
* Document `Headers.raw()` usage better
* 2.6.0
* fix import rule for stream PassThrough
* avoid named export for compatibility below node 10
* compress flag should not overwrite accept encoding header
* doc update
* 2.2.1
* v2.x readme overhaul with additions discussed in #448
added "comments" (TODO link references) for changes suggested but not yet implemented for future discussion/prs
clarified "native stream" to be "native Node streams"
adjusted all uses of http to https to encourage secure protocol usage
adjusted whatwg to proper case, WHATWG
made code block tags consistent as `js` instead of `javascript`
uppercased all method option values (post vs POST)
added spec-compliant node to the `response.ok` api section
* fix left over cruft, inconsistent hierarchy
This reverts commit fa6548ed31 (#441).
The autoClose option has been true by default since at least Node.js
v6.0.0. There is no need to set it once more.
Instead, make the example more realistic by handling stream outcomes
using a promise.
See #375.
This reverts commit ec29e3d264.
This patch prevents any agent being passed in which is not explicitly
an instance of `http.Agent`. This makes `node-fetch` no longer
compatible with https://npm.im/proxy-agent, which is one example of a
library that does not directly inherit from `http.Agent` directly.
Sorry for the revert -- I don't have an alternative patch because I
don't believe this is something node-fetch should be doing
automatically, because of how much of a limitation this could impose.
The original PR stated that this was to prevent requiring http/https,
and the effect would effectively be to force creation of an Agent on
every call. Note that this is already the behavior specified for
http.Agent when http.request received `false`. (See the bottom of the
[section on http.Agent in the Node
docs](https://nodejs.org/dist/latest-v7.x/docs/api/http.html#http_class_http_agent).
Cheers, and with apologies to @ahmadnassri for reverting their PR.