node-fetch
Advanced tools
Comparing version 2.6.9 to 2.7.0
@@ -1364,6 +1364,2 @@ process.emitWarning("The .es.js file is deprecated. Use .mjs instead."); | ||
if (!headers.has('Connection') && !agent) { | ||
headers.set('Connection', 'close'); | ||
} | ||
// HTTP-network fetch step 4.2 | ||
@@ -1742,4 +1738,7 @@ // chunked encoding is handled by Node.js | ||
response.once('close', function (hadError) { | ||
// tests for socket presence, as in some situations the | ||
// the 'socket' event is not triggered for the request | ||
// (happens in deno), avoids `TypeError` | ||
// if a data listener is still present we didn't end cleanly | ||
const hasDataListener = socket.listenerCount('data') > 0; | ||
const hasDataListener = socket && socket.listenerCount('data') > 0; | ||
@@ -1780,2 +1779,2 @@ if (hasDataListener && !hadError) { | ||
export default fetch; | ||
export { Headers, Request, Response, FetchError }; | ||
export { Headers, Request, Response, FetchError, AbortError }; |
@@ -1368,6 +1368,2 @@ 'use strict'; | ||
if (!headers.has('Connection') && !agent) { | ||
headers.set('Connection', 'close'); | ||
} | ||
// HTTP-network fetch step 4.2 | ||
@@ -1746,4 +1742,7 @@ // chunked encoding is handled by Node.js | ||
response.once('close', function (hadError) { | ||
// tests for socket presence, as in some situations the | ||
// the 'socket' event is not triggered for the request | ||
// (happens in deno), avoids `TypeError` | ||
// if a data listener is still present we didn't end cleanly | ||
const hasDataListener = socket.listenerCount('data') > 0; | ||
const hasDataListener = socket && socket.listenerCount('data') > 0; | ||
@@ -1790,1 +1789,2 @@ if (hasDataListener && !hadError) { | ||
exports.FetchError = FetchError; | ||
exports.AbortError = AbortError; |
{ | ||
"name": "node-fetch", | ||
"version": "2.6.9", | ||
"version": "2.7.0", | ||
"description": "A light-weight module that brings window.fetch to node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -390,3 +390,2 @@ node-fetch | ||
`Accept` | `*/*` | ||
`Connection` | `close` _(when no `options.agent` is present)_ | ||
`Content-Length` | _(automatically calculated, if possible)_ | ||
@@ -408,2 +407,4 @@ `Transfer-Encoding` | `chunked` _(when `req.body` is a stream)_ | ||
If no agent is specified, the default agent provided by Node.js is used. Note that [this changed in Node.js 19](https://github.com/nodejs/node/blob/4267b92604ad78584244488e7f7508a690cb80d0/lib/_http_agent.js#L564) to have `keepalive` true by default. If you wish to enable `keepalive` in an earlier version of Node.js, you can override the agent as per the following code sample. | ||
In addition, the `agent` option accepts a function that returns `http`(s)`.Agent` instance given current [URL](https://nodejs.org/api/url.html), this is useful during a redirection chain across HTTP and HTTPS protocol. | ||
@@ -410,0 +411,0 @@ |
Sorry, the diff of this file is not supported yet
162253
4626
635