Commit Graph

66 Commits

Author SHA1 Message Date
Alex Potsides 50536d1e02
fix: premature close with chunked transfer encoding and for async iterators in Node 12 (#1172)
* 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
2022-07-16 15:16:51 +02:00
Sesamestrong 8c197f8982 docs: Fix typos and grammatical errors in README.md (#686) 2019-10-21 15:32:52 +13:00
Richie Bendall 244e6f63d4
docs: Show backers in README 2019-10-07 20:23:11 +13:00
Richie Bendall 47a24a03eb
chore: Add opencollective badge 2019-10-02 22:00:55 +13:00
Richie Bendall 1d5778ad0d
docs: Add Discord badge 2019-09-08 10:00:54 +12:00
Steve Moser 086be6fc74 Remove --save option as it isn't required anymore (#581) 2019-08-09 11:17:25 +02:00
David Frank 95286f52bb
v2.6.0 (#638)
* 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
2019-05-16 14:38:28 +08:00
edgraaff bf8b4e8db3 Allow agent option to be a function (#632)
Enable users to return HTTP/HTTPS-specific agent based on request url
2019-05-05 20:12:33 +08:00
David Frank 0c2294ec48
2.5.0 release (#630)
* redirected property
* changelog update
* readme update
* 2.5.0
2019-05-01 13:05:32 +08:00
Andrew Leedham cfc8e5bad2 Swap packagephobia badge for flat style (#592) 2019-04-27 00:27:31 +08:00
David Frank e996bdab73
Quick readme update 2019-01-16 14:43:24 +08:00
Jonathan Puckey 35a4abe825 Fix spelling mistake (#551) 2018-11-15 11:38:19 +08:00
David Frank 5367fe6a97
v2.3.0 (#548)
* doc update
* handle corrupted location header during redirect
2018-11-13 14:35:09 +08:00
Joseph Nields ecd3d52c55 Add support for AbortSignal to cancel requests (#539)
Thx @jnields @FrogTheFrog @TimothyGu for their work!
2018-11-13 12:40:11 +08:00
David Frank 1daae67e9e
Fix import style to workaround node < 10 and webpack issues. (#544)
* 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
2018-11-05 17:42:51 +08:00
David Frank 8cc909f5ee
update readme to add credits and call for collaborators (#540)
* also pin chai-string to ~1.3.0 as chai-string 1.5.0 introduce a breaking change that breaks our node v4 CI.
2018-10-24 14:44:16 +08:00
Jared Kantrowitz 745a27c389 README update (#504)
* 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
2018-09-01 19:23:02 +08:00
Steven ecd82580aa Add badge to display install size (#455) 2018-07-22 13:34:32 -07:00
Bernhard K. Weisshuhn a33d6b0de1 mention agent options `family` and `lookup` in readme for reference 2018-06-19 12:52:13 -07:00
Timothy Gu 2b7e1ab27f Refine README example (#463)
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.
2018-05-28 12:26:22 +08:00
Deepak fa6548ed31 fix: add the autoClose: true to download file example (#441)
close #375
2018-04-08 10:27:47 +08:00
Timothy Gu 44c67b11a3
Add docs for v2.x 2018-02-03 12:33:32 -08:00
David Frank a9c76c19ac
adding comment to recommend 2.x branch (#367) 2017-11-22 17:55:39 +08:00
Jared Kantrowitz 553d50e804 Accept URLSearchParams as body (#297)
Fixes: #296
2017-06-12 13:29:50 +08:00
David Frank ed2f241df7 Update README.md
point to actual readme instead
2017-05-24 13:15:28 +08:00
David Frank b38e4a4257 Update README.md
point people to the new 1.x branch readme and changelog
2017-05-24 13:09:32 +08:00
David Frank 0fff17fbe9 Update README.md
Actually fix the readme this time...
2017-05-20 12:15:24 +08:00
David Frank 38d75d5a1f Mention 2.x alpha in the main readme 2017-05-15 20:24:52 +08:00
Alexander Tesfamichael 70e8483ac6 Document response.ok convenience property 2017-04-30 19:59:33 +02:00
Kat Marchán e5ff203ef4 Revert "Allow passing agent option as an object (#236)" (#263)
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.
2017-04-08 18:33:46 -07:00
Ahmad Nassri ec29e3d264 Allow passing agent option as an object (#236) 2017-04-03 02:54:31 -07:00
Timothy Gu a345c398b3 More documentation 2017-02-26 16:52:32 -08:00
Timothy Gu d23204b4ec README: remove trailing whitespace 2017-02-26 13:18:41 -08:00
Ahmad Nassri 673ebb2089 docs(defaults): list of default header values (#237)
Fixes #226.
2017-02-21 12:38:54 -08:00
Timothy Gu 9351084a98 Update README for ES2015 2016-12-12 12:55:28 -08:00
Timothy Gu 8f3e886c7f Switch to Codecov
Fixes #186.
2016-10-15 09:17:47 -07:00
Dan Dascalescu e67b3a8579 Fix run-on sentence about Options (#168)
[ci skip]
2016-10-08 13:37:49 -07:00
Chris Veness f30cce86c4 Add 'post JSON' example to readme (#173) 2016-10-08 13:35:19 -07:00
David Frank ff38361a9e a document for error handling 2016-09-26 14:03:00 +08:00
David Frank 43e06ca422 add catch example to readme 2016-09-24 17:21:40 +08:00
David Frank e574b497d5 make sure example is working 2016-08-16 20:22:18 +08:00
Jimmy Karl Roland Wärting d8c6969736 added 2 binary exemple
Got to many "how do i handle binary/images" issues
2016-08-16 11:40:31 +02:00
David Frank 8cce714b48 changelog and documentation update 2016-08-03 18:02:26 +08:00
David Frank 1cd0a5c570 Update doc to show redirect mode 2016-04-06 03:25:16 +08:00
David Frank 364edcf04b doc update 2016-04-06 01:32:37 +08:00
David Frank 565ec4b35a additional tests for the new form-data integration 2015-07-22 15:40:52 +08:00
Dylan Piercey ffac4177b0 Automatically pull headers from node-form-data. 2015-07-22 02:05:06 +00:00
David Frank 55cde9e7de update document 2015-05-03 18:07:20 +08:00
Rhys Evans 5e4d9b1a60 expose response and headers constructors 2015-05-03 09:43:59 +01:00
David Frank 3f3d34d492 update doc and changelog 2015-04-17 13:31:58 +08:00