Skip to content

Commit aa49bf5

Browse files
lpincaBethGriggs
authored andcommitted
doc: clarify http.Agent constructor options
PR-URL: #26412Fixes: #26357 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Masashi Hirano <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent a562aba commit aa49bf5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

‎doc/api/http.md‎

Lines changed: 8 additions & 2 deletions
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)