Skip to content

Commit 8b8297d

Browse files
lpincaBridgeAR
authored andcommitted
doc: clarify http.Agent constructor options
PR-URL: #26412 Fixes: #26357 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Masashi Hirano <shisama07@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 1d279ac commit 8b8297d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

doc/api/http.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,19 @@ added: v0.3.4
116116
Can have the following fields:
117117
* `keepAlive` {boolean} Keep sockets around even when there are no
118118
outstanding requests, so they can be used for future requests without
119-
having to reestablish a TCP connection. **Default:** `false`.
119+
having to reestablish a TCP connection. Not to be confused with the
120+
`keep-alive` value of the `Connection` header. The `Connection: keep-alive`
121+
header is always sent when using an agent except when the `Connection`
122+
header is explicitly specified or when the `keepAlive` and `maxSockets`
123+
options are respectively set to `false` and `Infinity`, in which case
124+
`Connection: close` will be used. **Default:** `false`.
120125
* `keepAliveMsecs` {number} When using the `keepAlive` option, specifies
121126
the [initial delay](net.html#net_socket_setkeepalive_enable_initialdelay)
122127
for TCP Keep-Alive packets. Ignored when the
123128
`keepAlive` option is `false` or `undefined`. **Default:** `1000`.
124129
* `maxSockets` {number} Maximum number of sockets to allow per
125-
host. **Default:** `Infinity`.
130+
host. Each request will use a new socket until the maximum is reached.
131+
**Default:** `Infinity`.
126132
* `maxFreeSockets` {number} Maximum number of sockets to leave open
127133
in a free state. Only relevant if `keepAlive` is set to `true`.
128134
**Default:** `256`.

0 commit comments

Comments
 (0)