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

Function responseOnEnd

lib/_http_client.js:858–890  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

856}
857
858function responseOnEnd() {
859 const req = this.req;
860 const socket = req.socket;
861
862 if (socket) {
863 if (req.timeoutCb) socket.removeListener('timeout', emitRequestTimeout);
864 socket.removeListener('timeout', responseOnTimeout);
865 }
866
867 req._ended = true;
868
869 if (!req.shouldKeepAlive) {
870 if (socket.writable) {
871 debug('AGENT socket.destroySoon()');
872 if (typeof socket.destroySoon === 'function')
873 socket.destroySoon();
874 else
875 socket.end();
876 }
877 assert(!socket.writable);
878 } else if (req.writableFinished && !this.aborted) {
879 assert(req.finished);
880 // We can assume `req.finished` means all data has been written since:
881 // - `'responseOnEnd'` means we have been assigned a socket.
882 // - when we have a socket we write directly to it without buffering.
883 // - `req.finished` means `end()` has been called and no further data.
884 // can be written
885 // In addition, `req.writableFinished` means all data written has been
886 // accepted by the kernel. (i.e. the `req.socket` is drained).Without
887 // this constraint, we may assign a non drained socket to a request.
888 responseKeepAlive(req);
889 }
890}
891
892function responseOnTimeout() {
893 const req = this._httpMessage;

Callers

nothing calls this directly

Calls 5

responseKeepAliveFunction · 0.85
assertFunction · 0.70
debugFunction · 0.50
removeListenerMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…