Commit Graph

148 Commits

Author SHA1 Message Date
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 <[email protected]>
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 <[email protected]>
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
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
Kat Marchán 09f2e30557 headers.get: add space to join (#257)
The behavior was changed in whatwg/fetch#504.
2017-04-02 08:43:46 -07:00
Gajus Kuizinas 4804a40c17 Add a special case for constructing Headers with Headers (#253)
Fixes: #251.
2017-03-20 09:22:49 -07:00
Grzegorz Graczyk a1e76b97e1 More lenient gzip decompression (#239)
Ref: https://github.com/nodejs/node/issues/8701#issuecomment-268224481
Ref: https://github.com/request/request/issues/2482
Ref: https://github.com/request/request/pull/2492
Fixes: http://www.mantovanispa.it
Fixes: #139
2017-02-27 10:02:45 -08:00
Timothy Gu e284841db9 test: use fetch.Promise consistently
On Node.js v4, Babel polyfills `Promise`.
2017-02-26 17:00:01 -08:00
Timothy Gu 25e43a8f3e Export FetchError and update ERROR-HANDLING.md 2017-02-26 16:46:34 -08:00
Timothy Gu 55e573b741 Back to 100% coverage 2017-02-26 15:30:43 -08:00
Timothy Gu b899649c32 Remove bluebird 2017-02-26 14:42:46 -08:00
Timothy Gu 56f786f896 Update deps and remove 0.12 compat 2017-02-26 14:12:45 -08:00
Timothy Gu 11a9481405 request: overwrite Content-Length if possible
Also reorganize header normalization
2017-01-29 10:06:54 -08:00
Timothy Gu ac8ddaccb8 Improve Headers constructor argument processing 2017-01-29 08:58:16 -08:00
Timothy Gu e9db869523 Remove FOLLOW_SPEC option; make it the default behavior (#225)
* Remove !FOLLOW_SPEC mode

* Update UPGRADE-GUIDE

* Add CHANGELOG entry
2017-01-23 07:54:28 -08:00
Timothy Gu 502b604208 Fix Headers iterable initializer handling 2017-01-14 21:22:23 -08:00
Timothy Gu f198f93767 test: remove fallbacks for Node.js 0.10 2017-01-14 20:56:26 -08:00
Timothy Gu 151de2bdfb Use ES2015 export syntax (#212)
* Implement Rollup's external module check

* Use ES2015 export syntax

More friendly to ES2015 environments.
2017-01-14 20:50:10 -08:00
Nathan Rajlich fa22529128 proper stack first line for FetchError instances (#215)
The `.stack` property gets cached in the `captureStackTrace()` call, so
whatever is set as the `name` and `message` at that time will be used
for the first line of the stack trace.

Before this patch, FetchError's stack would just say "Error" as the
first line. Now they correctly display the "${name}: ${message}" of the
error instances.

Test case included.

Signed-off-by: Timothy Gu <[email protected]>
2016-12-14 15:41:35 -08:00