Commit Graph

163 Commits

Author SHA1 Message Date
Jimmy Wärting f5d3cf5e25
fix(Headers): don't forward secure headers to 3th party (#1449)
* fix(Headers): don't forward secure headers to 3th party
* added more narrow test for isDomainOrSubdomain
2022-01-14 15:55:41 +01:00
Jimmy Wärting 4ae35388b0
core: Warn when using data (#1421)
* Add a warning when using .data in RequestInit

* Add a warning when using .data in Response

* Switch custom solution for utils.deprecate

* Remove unused line in request tests

* moved error handler into the body class

* lint fix

Co-authored-by: Lubomir <lubomir.yudenko@gmail.com>
2022-01-08 14:19:27 +01:00
dnalborczyk 41f53b9065
fix: use more node: protocol imports (#1428)
* fix: use node: protocol

* use node: protocol in readme
2021-12-28 16:39:53 +01:00
Jimmy Wärting 1493d046bc
core: Don't use global buffer (#1422)
* remove unused file

* two test is coveraged by the Uint8Array test

* use arrayBuffer to test base64 instead

* avoid testing buffer

* avoid using Buffer

* import buffer module

* use one same textEncoder

* import stream consumer that can test iterable objects

* fix a test

* fix test where type should be empty
2021-12-21 20:34:30 +01:00
Maxim Shirshin eb33090b81
Chore: Fix logical operator priority (regression) to disallow GET/HEAD with non-empty body (#1369) 2021-12-06 17:14:42 +01:00
Jimmy Wärting 6956bf868b
core: Don't use buffer to make a blob (#1402) 2021-11-30 10:40:04 +01:00
Tasos Bitsios 6e4c1e4f67
fix(Redirect): Better handle wrong redirect header in a response (#1387)
* Fixed crash when an invalid Location URL is returned from a redirect. Fixes #1386

* CHANGELOG entry

* changed catch(e) -> catch(error) to match rest of code, added comment

Co-authored-by: Linus Unnebäck <linus@folkdatorn.se>

* suppress error on invalid redirect URL when options.redirect == manual

Co-authored-by: Tasos Bitsios <tasos.bitsios@import.io>
Co-authored-by: Linus Unnebäck <linus@folkdatorn.se>
2021-11-26 11:19:25 +01:00
Dmitry Merkulov 2d5399ed56
fix: handle errors from the request body stream (#1392)
* fix: handle errors from the request body stream

* lint: fix linting

Co-authored-by: Linus Unnebäck <linus@folkdatorn.se>
2021-11-19 14:40:51 +01:00
Jimmy Wärting 0284826de6
fix(http.request): Cast URL to string before sending it to NodeJS core (#1378)
* Add some jsdoc

* cast url to string before sending it to NodeJS core
2021-11-12 12:37:51 +01:00
Jimmy Wärting 3944f24770
feat(Body): Added support for `BodyMixin.formData()` and constructing bodies with FormData (#1314)
Added support for body toFormData
2021-11-08 12:51:49 +01:00
Travis D. Warlick, Jr 2d80b0bb3f
Add support for Referrer and Referrer Policy (#1057)
* Support referrer and referrerPolicy

* Test TS types for addition of referrer and referrerPolicy

* Fix lint issues and merge error
2021-11-05 10:26:13 +01:00
dnalborczyk 47d9cde0b0
refactor: use node: prefix for imports (#1346)
* refactor: use node: prefix for imports
2021-10-26 11:06:52 +02:00
David Kingdon acc2cbaebd
Update response.js (#1162)
Allow Response.clone() to persist the high water mark
2021-10-06 22:07:24 -04:00
Jimmy Wärting 8721d79208
fix(Body.body): Normalize `Body.body` into a `node:stream` (#924)
* body conversion and test

* also handle blobs

* typeof null is object

* test for blob also

* lowercase boundary are easier

* unreachable code, body should never be a blob or buffer any more.

* stream singleton

* use let

* typo

* convert blob stream into a whatwg stream

* lint fix

* update changelog

Co-authored-by: Antoni Kepinski <xxczaki@pm.me>
2021-09-14 11:39:33 +02:00
Ambrose Chua 8b54ab4509
fix: Pass url string to http.request (#1268)
* fix: IPv6 literal parsing

* docs: Explain why search is overwritten

* test: Document the reason for square brackets

* docs: Mention basic auth support as a difference

* fix: Raise a TypeError when URL includes credentials
2021-09-09 06:02:05 +02:00
Jimmy Wärting 471f08c15c
fix(Body): Discurage form-data and buffer() (#1212)
warn about using form-data
2021-09-05 01:14:38 +02:00
Travis D. Warlick, Jr 51861e98a8
Fix(premature close) Redirect failing when response is chunked but empty (#1222)
* Fix redirect failing when response is chunked but empty. #1220 #1064

* Handle chunked responses where the final chunk and EOM code are in separate packets and where there is an additional data chunk in the same packet before the final chunk and EOM code.
2021-08-12 18:37:22 +02:00
Antoni Kepinski b50fbc1057
Require Node.js 12.20.0 and move to ESM (#1141)
* Use ESM import in runkit example file

* Update dependencies, version and transition to ESM

* Use ESM imports, add ESM-related info

* Remove rollup

* Lint TypeScript-related files

* Update dependency

* Lint & update dependency

* Lint

* Remove commonjs tests

* chore: update changelog

* Remove commonjs GitHub action

* Update funding.yml

* Update linter rules

* Lint

* Fix tsd

* Remove unnecessary types

* Simplify

* Use top-level await

* Update GitHub Actions

* Use Mocha with ESM

* Revamp

* specify what node version

* update formdata-node dep

* remove lint from example using top await

* updated name and link to formdata-polyfill

* Stop recommend form-data

* filter example - it has many duplicate variables

* Update type definitions to ESM

* Remove unused lint rule disable comment

* Remove leftover rollup and dist folder

* updated depn

* updated d.ts

* lint

* Fix breaking changes with blob v3 stream()

* revert eslint comment

* revert back to xo 0.39

Don't want to deal with all those new rules right now. will fix it later
fixed some of them...

* none TS fan trying to fix type definition

* Give me a break

* Test on all minimum supported Node.js versions (#1170)

* Test on all minimum supported Node.js versions

* Tweak Node.js workaround version range

* Handle Node.js 16 aborted error message

* fix node version string compare

Co-authored-by: Jimmy Wärting <jimmy@warting.se>

* bumped fetch-blob version

* import from dom lib

* rm unused comment

* updated required version in docs

* fixed named import

* set lowest support to 12.20.0

* comment explaining both

* rm log

Co-authored-by: Jimmy Wärting <jimmy@warting.se>
Co-authored-by: Linus Unnebäck <linus@folkdatorn.se>
2021-07-18 22:15:19 +02:00
Josephus Paye II ffef5e3c23
Fix `this` arg for URLSearchParams prototype call (#1111) 2021-05-04 00:28:50 +02:00
Tanguy Krotoff 3b50b0c4e6
Add support for Response.error() (#1078) 2021-05-03 23:09:37 +02:00
Travis D. Warlick, Jr 8eeeec18c1
Fix premature close with chunked transfer encoding and for async iterators in Node 12 (#1064)
Co-authored-by: Irakli Gozalishvili <contact@gozala.io>
2021-02-23 07:14:09 +00:00
Leonardo Quixada 6ee9d3186f
Improve Header's forEach method compliance with browser implementation. (#1074)
* Improve Header's forEach method compliance with browser implementation.

* Replaced callback.call with Reflect.apply on Headers' forEach.

* Set undefined as default value for Header' forEach second argument.

* Rewrote test case where 'this' is undefined.

* Ignored lint issues (no-eq-null and eqeqeq).
2021-01-25 19:59:55 -05:00
Travis D. Warlick, Jr cb032ea44f
Throw a `TypeError` on an invalid redirect option (#1019) 2021-01-01 18:38:44 +13:00
Travis D. Warlick, Jr 5c657e7990
Fix missing return after reject (#1022)
The bad Location header is escaped by the URL module, so any "corrupted" headers become valid or otherwise cause errors earlier in processing
2021-01-01 18:38:11 +13:00
William Orr 1f4f85e1bb
Support instances of `EventTarget` as a `signal` (#1001)
Co-authored-by: Richie Bendall <richiebendall@gmail.com>
2021-01-01 18:37:26 +13:00
Travis D. Warlick, Jr c86886249a
Allow `signal` to be `null` or `undefined` (#1050) 2021-01-01 18:35:46 +13:00
Jimmy Wärting cbd4d89576
Minor optimization (#956) 2020-09-18 12:33:15 +02:00
Antoni Kepinski eaff0094c4
Honor the `size` option after following a redirect 2020-09-05 14:44:41 +02:00
Nick K a38b533ad6
feat: Implement form-data encoding (#603)
Co-authored-by: Steve Moser <contact@stevemoser.org>
Co-authored-by: Antoni Kepinski <xxczaki@pm.me>
Co-authored-by: Richie Bendall <richiebendall@gmail.com>
Co-authored-by: Konstantin Vyatkin <tino@vtkn.io>
Co-authored-by: aeb-sia <50743092+aeb-sia@users.noreply.github.com>
Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com>
Co-authored-by: Erick Calder <e@arix.com>
Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-06-10 22:31:35 +02:00
Konstantin Vyatkin 2d796bde76
upgrade fetch-blob to 1.0.7 (#870)
Co-authored-by: Antoni Kepinski <xxczaki@pm.me>
2020-06-10 21:14:32 +02:00
Konstantin Vyatkin 8f406b789a
chore: remove code duplication in custom errors (#842)
* remove code duplication in custom errors

* check using base class
2020-06-10 07:17:35 -04:00
Konstantin Vyatkin 1cb9070cce
[Spec] Should check body _source_ on redirect (#866)
* correct stream tests

* bump Node.JS min to 10.17

* lint
2020-06-10 07:16:51 -04:00
Konstantin Vyatkin df1a4fafa9
fix: Correct Node versions were not installed on test matrix (#846)
* fix Node install and add engines

* use minimum-node-version
2020-06-09 20:26:24 -04:00
Konstantin Vyatkin 5c909797d6
Polyfill `http.validateHeaderName` and `http.validateHeaderValue` (#843)
* prefer native node function

* use RegExp from Node 14.3
2020-06-09 19:51:22 -04:00
Moni d351058cae
Update Url (#864) 2020-06-05 19:00:13 +02:00
Christian Kruse af7e67f504
Add insecureHTTPParser Parameter (#856)
Keep whitespace consistent
2020-06-04 11:54:02 -04:00
Konstantin Vyatkin 69d25b904a
Fix Data URI handling and drop all URL analysis RegExps (#853)
* add breaking test
* don't use RegExp for URLs
2020-05-31 11:15:27 -04:00
Maxime LUCE e6bfe4d419
fix: improve TypeScript types (#841)
* fix: improve TypeScript types

* fix: disable allowSyntheticDefaultImports and esModuleInterop

* fix: improve HeadersInit types (js/ts)

* fix: fully match types to build index.cjs

* fix: allow Iterable<Iterable<string>> in HeadersInit
2020-05-28 20:41:26 -04:00
Konstantin Vyatkin 769f75d054
Drop custom Promises and refactor to `async` functions (#845)
* refactor to async

* no custsom promises anymore

* restore server premature handler

* simplify

* fixing break

* lint

* remove promise dependency

* fix docs
2020-05-28 23:57:57 +02:00
Antoni Kepinski 079b11e257
fix: export 2020-05-25 19:20:30 +02:00
Antoni Kepinski fa627f4b0c
Follow xo linter rules more strictly (#829)
Co-authored-by: Moni <40552237+NotMoni@users.noreply.github.com>
2020-05-25 17:11:56 +02:00
Konstantin Vyatkin b3878b9a3e
Fix default user agent string (#818)
Co-authored-by: Antoni Kepinski <xxczaki@pm.me>
2020-05-25 16:56:04 +02:00
Konstantin Vyatkin ca4703dd15
revamp Headers module (#834)
Co-authored-by: Antoni Kepinski <xxczaki@pm.me>
2020-05-25 16:43:10 +02:00
Richie Bendall 94e5b92de1
Remove `timeout` option (#831) 2020-05-25 13:30:05 +02:00
Antoni Kepinski 498710d555
make sure the default `highWaterMark` equals 16384 2020-05-24 12:16:34 +02:00
Antoni Kepinski c822ff4719
Replace istanbul ignore next with c8 ignore next 2020-05-24 00:28:17 +02:00
Konstantin Vyatkin 924c12244a
use proper class inheritance (#828) 2020-05-23 13:41:14 -04:00
Konstantin Vyatkin ead6b458e9
normalize export (#827) 2020-05-23 13:32:10 -04:00
Jonathan Stewmon bea4a7cb73
fix: Settle `consumeBody` promise when the response closes prematurely (#768)
The stream.finished function is used consolidate the terminal cases.
The writable option must be set to false, since the body stream is
a Duplex stream, but our terminal cases only apply to the Readable side.
2020-05-23 08:28:38 -04:00
Konstantin Vyatkin dde507cef7
Remove guard for Stream.Readable.destroy (#824) 2020-05-23 12:00:31 +02:00