Add Brotli support in Request (#819)

* document and request brotli

* Document different minimum version

Co-authored-by: Richie Bendall <richiebendall@gmail.com>
This commit is contained in:
Konstantin Vyatkin 2020-05-22 22:48:14 -04:00 committed by GitHub
parent 912348d5dc
commit 28655e1390
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 5 deletions

View File

@ -430,7 +430,7 @@ If no values are set, the following request headers will be sent automatically:
| Header | Value |
| ------------------- | -------------------------------------------------------- |
| `Accept-Encoding` | `gzip,deflate` _(when `options.compress === true`)_ |
| `Accept-Encoding` | `gzip,deflate,br` _(when `options.compress === true`)_ |
| `Accept` | `*/*` |
| `Connection` | `close` _(when no `options.agent` is present)_ |
| `Content-Length` | _(automatically calculated, if possible)_ |

View File

@ -7,6 +7,7 @@ Changelog
**Work in progress!**
- **Breaking:** minimum supported Node.js version is now 10.16.
- Enhance: improve coverage.
- Enhance: drop Babel (while keeping ESM) (#805).
- Fix: export the `AbortError` class.

View File

@ -19,7 +19,7 @@ other comparatively minor modifications.
# Breaking Changes
## Minimum supported Node.js version is now 10
## Minimum supported Node.js version is now 10.16
Since Node.js will deprecate version 8 at the end of 2019, we decided that node-fetch v3.x will not only drop support for Node.js 4 and 6 (which were supported in v2.x), but also for Node.js 8. We strongly encourage you to upgrade, if you still haven't done so. Check out Node.js' official [LTS plan] for more information on Node.js' support lifetime.

View File

@ -16,7 +16,7 @@
"*.d.ts"
],
"engines": {
"node": ">=10"
"node": ">=10.16"
},
"scripts": {
"build": "rollup -c",

View File

@ -284,7 +284,7 @@ export default function fetch(url, options_) {
}
// For br
if (codings === 'br' && typeof zlib.createBrotliDecompress === 'function') {
if (codings === 'br') {
body = pump(body, zlib.createBrotliDecompress(), error => {
reject(error);
});

View File

@ -239,7 +239,7 @@ export function getNodeRequestOptions(request) {
// HTTP-network-or-cache fetch step 2.15
if (request.compress && !headers.has('Accept-Encoding')) {
headers.set('Accept-Encoding', 'gzip,deflate');
headers.set('Accept-Encoding', 'gzip,deflate,br');
}
let {agent} = request;