Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8b3320d

Browse files
authored
fix: Remove the default connection close header. (#1736)
Instead, we rely on the underlying http implementation in Node.jsto handle this, as per the documentation athttps://nodejs.org/api/http.html#new-agentoptionsThisfixes#1735 and likely replaces#1473The original change introducing this provided no clear motivationfor the override, and the implementation has since been changed todisable this header when an agent is provided, so I think thereis sufficient evidence that removing this is the correct behaviour.af21ae67f68577
1 parent7b86e94 commit8b3320d

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,6 @@ If no values are set, the following request headers will be sent automatically:
539539
| -------------------| ------------------------------------------------------|
540540
|`Accept-Encoding`|`gzip, deflate, br` (when`options.compress === true`)|
541541
|`Accept`|`*/*`|
542-
|`Connection`|`close`_(when no`options.agent` is present)_|
543542
|`Content-Length`|_(automatically calculated, if possible)_|
544543
|`Host`|_(host and port information from the target URI)_|
545544
|`Transfer-Encoding`|`chunked`_(when`req.body` is a stream)_|
@@ -558,6 +557,8 @@ The `agent` option allows you to specify networking related options which are ou
558557

559558
See[`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options) for more information.
560559

560+
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.
561+
561562
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.
562563

563564
```js

‎src/request.js‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,6 @@ export const getNodeRequestOptions = request => {
288288
agent=agent(parsedURL);
289289
}
290290

291-
if(!headers.has('Connection')&&!agent){
292-
headers.set('Connection','close');
293-
}
294-
295291
// HTTP-network fetch step 4.2
296292
// chunked encoding is handled by Node.js
297293

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp