From b3878b9a3e42ab4f2362ecc24790ee6a689edb2e Mon Sep 17 00:00:00 2001 From: Konstantin Vyatkin Date: Mon, 25 May 2020 10:56:04 -0400 Subject: [PATCH] Fix default user agent string (#818) Co-authored-by: Antoni Kepinski --- README.md | 17 +++++++++-------- src/request.js | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fdd43aa..f3e177a 100644 --- a/README.md +++ b/README.md @@ -427,14 +427,15 @@ The default values are shown after each option key. If no values are set, the following request headers will be sent automatically: -| Header | Value | -| ------------------- | -------------------------------------------------------- | -| `Accept-Encoding` | `gzip,deflate,br` _(when `options.compress === true`)_ | -| `Accept` | `*/*` | -| `Connection` | `close` _(when no `options.agent` is present)_ | -| `Content-Length` | _(automatically calculated, if possible)_ | -| `Transfer-Encoding` | `chunked` _(when `req.body` is a stream)_ | -| `User-Agent` | `node-fetch (+https://github.com/node-fetch/node-fetch)` | +| Header | Value | +| ------------------- | ------------------------------------------------------ | +| `Accept-Encoding` | `gzip,deflate,br` _(when `options.compress === true`)_ | +| `Accept` | `*/*` | +| `Connection` | `close` _(when no `options.agent` is present)_ | +| `Content-Length` | _(automatically calculated, if possible)_ | +| `Transfer-Encoding` | `chunked` _(when `req.body` is a stream)_ | +| `User-Agent` | `node-fetch` | + Note: when `body` is a `Stream`, `Content-Length` is not set automatically. diff --git a/src/request.js b/src/request.js index 4a32161..b8b7ea1 100644 --- a/src/request.js +++ b/src/request.js @@ -217,7 +217,7 @@ export function getNodeRequestOptions(request) { // HTTP-network-or-cache fetch step 2.11 if (!headers.has('User-Agent')) { - headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'); + headers.set('User-Agent', 'node-fetch'); } // HTTP-network-or-cache fetch step 2.15