Commit Graph

167 Commits

Author SHA1 Message Date
Jimmy Wärting afb36f6c17
Revert "fix: handle bom in text and json (#1739)" (#1741)
This reverts commit 29909d75c6.
2023-05-09 13:05:46 +02:00
Alexis Clarembeau 29909d75c6
fix: handle bom in text and json (#1739)
* fix: handle bom in text and json
* add unit tests
2023-05-08 18:19:42 +02:00
victal fddad0e7ea
fix(headers): don't forward secure headers on protocol change (#1605)
backport for #1599 to the 2.x branch

Co-authored-by: Guilherme Victal <guilherme.a@dasa.com.br>
2022-07-19 22:38:01 +02:00
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
Maciej Goszczycki 838d9713ef
Handle zero-length OK deflate responses (#903) 2022-01-17 00:40:12 +01:00
Jimmy Wärting 1ef4b560a1
backport of #1449 (#1453)
* backport of #1449

* bump patch version
2022-01-16 12:45:33 +01:00
Jimmy Wärting f56b0c66d3
fix(URL): prefer built in URL version when available and fallback to whatwg (#1352)
* fix(URL): prefer built in URL version when available and fallback to whatwg

* bump minor
2021-10-31 16:40:17 +01:00
Jimmy Wärting 18193c5922
fix v2.6.3 that did not sending query params (#1301) 2021-09-21 16:42:50 +02:00
Linus Unnebäck ace7536c95
fix: properly encode url with unicode characters (#1291)
* fix: properly encode url with unicode characters
* release: 2.6.3
2021-09-20 16:09:10 +02:00
Antoni Kepinski 2358a6c256
Honor the `size` option after following a redirect and revert data uri support
Co-authored-by: Richie Bendall <richiebendall@gmail.com>
2020-09-05 14:55:39 +02:00
dsuket 6a5d192034 fix: Properly parse meta tag when parameters are reversed (#682) 2019-10-07 19:58:27 +13:00
Richie Bendall eb3a57255b
feat: Data URI support (#659)
Adds support for Data URIs using native methods in Node 5.10.0+
2019-09-08 09:44:40 +12: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
Justin Beckwith a35dcd14a3 chore(deps): address deprecated url-search-params package (#622) 2019-05-01 11:14:11 +08:00
David Frank 49d77600a7
Pass custom timeout to subsequent requests on redirect (#615) 2019-04-27 00:46:53 +08:00
Muhammet Öztürk 2a2d4384af Adding Brotli Support (#598)
* adding brotli support
* support old node versions
* better test
2019-04-27 00:20:15 +08:00
David Frank 05f5ac12a2
Node 12 compatibility (#614)
* dev package bump
* test invalid header differently as node 12 no longer accepts invalid headers in response
* add node v10 in travis test list as node 12 has been released
2019-04-27 00:11:52 +08:00
Jimmy Wärting 432c9b01ea support reading blob with stream (#608) 2019-04-16 18:29:17 +08:00
Jimmy Wärting 0ad136d49f Added new reading method to blob 2019-04-15 22:46:11 +02:00
Kevin (Kun) "Kassimo" Qian 1c2f07ffb8 Headers should not accept empty field name (#562) 2018-12-29 17:04:44 +08:00
Jimmy Wärting 2d0fc689c6 Clone URLSearchParams to avoid mutation (#547)
* And make sure Request/Response set Content-Type per Fetch Spec
* And make sure users can read the body as string via text()
2018-11-14 00:36:44 +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
Timothy Gu b091ab5917
Fix up ArrayBufferView support (#464)
Also add more test coverage.

Fixes: #482
Closes: #484
2018-07-21 22:13:01 -07:00
Bernhard K. Weisshuhn 287bc3bdcf test agent option `family` being passed to `lookup` 2018-06-19 12:52:13 -07:00
Bernhard K. Weisshuhn b2c5f543ce test supplying a lookup function through an agent 2018-06-19 12:52:13 -07:00
Nazar Mokrynskyi 5bc23d81cf Added support for `ArrayBufferView` (#457) 2018-05-28 11:18:17 +08:00
Timothy Gu f6683aa49c Add a test case for invalid headers
See feae6d6ec8.
2018-03-25 13:45:26 -07:00
Timothy Gu 13b230b30b Add a test for redirect with stream body
See 35722f19e5.
2018-03-25 13:45:26 -07:00
Timothy Gu 8aac53679d
Fix custom Host header with arbitrary case (#430)
Regression since 1592ca1148.

Fixes: #416
Fixes: #425
2018-03-22 22:01:45 -07:00
Jason Rogers c012c4116b Reject when stream accumulation fails (#415)
Fixes: #414
2018-03-22 18:38:03 -07:00
William MacDonald 4c4f2f29e5 Wrap ArrayBuffer with Buffer internally to fix Body methods (#426) 2018-03-20 09:57:03 -07:00
Timothy Gu 780598ad72
Harmonize style (#413) 2018-03-04 20:29:12 -08:00
Timothy Gu 35722f19e5 Significant rework of redirection
- Handle Location-less redirect like non-redirect response.
- Include bodies when redirecting to non-POST 301/302 and all 307/308
  response.

Co-authored-by: Gregor Martynus <gregor@martynus.net>
2018-03-04 20:25:16 -08:00
Gregor Martynus fc539951ca Support ArrayBuffer as body (#408) 2018-03-04 16:40:39 -08:00
Timothy Gu b1cd2dd438
Better compliance with Web IDL
- Make read-only attributes actually read-only
- Set @@toStringTag on the prototype only
- Make prototype methods/getters enumerable

Based on #354.

Co-authored-by: Benjamin Seber <seber@synyx.de>
2018-02-03 12:12:14 -08:00
Timothy Gu dccef32e81
Refactor tests 2018-02-03 12:11:50 -08:00
Timothy Gu bc6f0da3ac
Remove Blob#close per spec change
See https://github.com/w3c/FileAPI/pull/68.
2018-02-03 11:19:32 -08:00
Moritz 19b115f9dc Add error event hander for the body stream even if the body isn't accessed (#379)
Fixes #378
2018-01-27 11:20:05 -08:00
David Frank 3345b652e4
fix a small oversight in request class
lowercase method name does not trigger type error properly (#362)
2017-11-19 12:44:02 +08:00
Timothy Gu e7c1ef88ed Update deps (#320) 2017-07-28 12:12:54 +08:00
David Frank 9bd099a779 workaround slow nodejs 8 spawn on travis ci by increasing timeout for test cases 2017-07-22 21:11:25 +08:00
David Frank 70cd403914 do not make request to example.com, use local server instead, avoid UnhandledPromiseRejectionWarning altogether 2017-07-22 21:04:59 +08:00
Jared Kantrowitz 432cd8a31e remove `encoding` as a dependency, throw detailed Error if not installed (#302)
* remove `encoding` as a dependency, throw descriptive Error if textConverted() is used without it in env

* remove rollup ext dep resolution since we don't need it

* switch to programmer error, rm unneeded test conditions, bump timeout for slow CI

* more kill `encoding` dep PR changes

keep blank "dependencies" prop in package.json so rollup's external config func doesn't seize
add ext dep checks back to the rollup config
no implicit var
clarify test comment

* [squash] alter travis cfg to test with and without `encoding`, various

fix devDeps
separate `encoding` tests to their own block

* [squash] fixing nits

* [squash] ci: full matrix of form-data versions and encoding existence

and nits
2017-07-02 12:32:48 -04:00
Jared Kantrowitz 76e8ad8b24 refactor deprecated `new Buffer` with Buffer.from and Buffer.alloc (#299)
* refactor deprecated `new Buffer` with Buffer.from and Buffer.alloc

* don't need new ArrayBuffer instance when already an ArrayBuffer
2017-06-19 20:41:05 -04:00
jared kantrowitz 1804041726 wrap JSON.parse's SynaxError with FetchError 2017-06-19 20:31:15 -04:00
Jared Kantrowitz 553d50e804 Accept URLSearchParams as body (#297)
Fixes: #296
2017-06-12 13:29:50 +08:00
David Frank c24d591794 fix test server for node 8, which changes keepalive connection handling 2017-06-03 18:01:13 +08:00