MCPcopy Index your code
hub / github.com/nodejs/node / responseKeepAlive

Function responseKeepAlive

lib/_http_client.js:827–856  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

825
826// client
827function responseKeepAlive(req) {
828 const socket = req.socket;
829
830 debug('AGENT socket keep-alive');
831 if (req.timeoutCb) {
832 socket.setTimeout(0, req.timeoutCb);
833 req.timeoutCb = null;
834 }
835 socket.removeListener('close', socketCloseListener);
836 socket.removeListener('error', socketErrorListener);
837 socket.removeListener('data', socketOnData);
838 socket.removeListener('end', socketOnEnd);
839
840 // TODO(ronag): Between here and emitFreeNT the socket
841 // has no 'error' handler.
842
843 // There are cases where _handle === null. Avoid those. Passing undefined to
844 // nextTick() will call getDefaultTriggerAsyncId() to retrieve the id.
845 const asyncId = socket._handle ? socket._handle.getAsyncId() : undefined;
846 // Mark this socket as available, AFTER user-added end
847 // handlers have a chance to run.
848 defaultTriggerAsyncIdScope(asyncId, process.nextTick, emitFreeNT, req);
849
850 req.destroyed = true;
851 if (req.res) {
852 // Detach socket from IncomingMessage to avoid destroying the freed
853 // socket in IncomingMessage.destroy().
854 req.res.socket = null;
855 }
856}
857
858function responseOnEnd() {
859 const req = this.req;

Callers 2

responseOnEndFunction · 0.85
requestOnFinishFunction · 0.85

Calls 5

getAsyncIdMethod · 0.80
debugFunction · 0.50
setTimeoutMethod · 0.45
removeListenerMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…