[v6.x] http: overridable keep-alive behavior of `Agent`
Backport of:
https://github.com/nodejs/node/pull/13005
cc @MylesBorins @nodejs/lts
—-
Introduce two overridable Agent
methods:
keepSocketAlive(socket)
reuseSocket(socket, req)
These methods can be overridden by particular Agent
class child to
make keep-alive behavior customizable.
Motivation: destroy persisted sockets after some configurable timeout.
It is very non-trivial to do it with available primitives. Such program
will most likely need to poke with undocumented events and methods of
Agent
. With introduced API such behavior is easy to implement.
PR-URL: https://github.com/nodejs/node/pull/13005 Reviewed-By: Matteo Collina matteo.collina@gmail.com Reviewed-By: Refael Ackermann refack@gmail.com Reviewed-By: Colin Ihrig cjihrig@gmail.com Reviewed-By: Brian White mscdex@mscdex.net Reviewed-By: Michael Dawson michael_dawson@ca.ibm.com
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines