Skip to content

http: abortIncoming only on socket close #36821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,7 @@ function socketOnTimeout() {

function socketOnClose(socket, state) {
debug('server socket close');
// Mark this parser as reusable
if (socket.parser) {
freeParser(socket.parser, null, socket);
}

freeParser(socket.parser, null, socket);
abortIncoming(state.incoming);
}

Expand All @@ -602,18 +598,15 @@ function socketOnEnd(server, socket, parser, state) {

if (ret instanceof Error) {
debug('parse error');
// socketOnError has additional logic and will call socket.destroy(err).
FunctionPrototypeCall(socketOnError, socket, ret);
return;
}

if (!server.httpAllowHalfOpen) {
abortIncoming(state.incoming);
if (socket.writable) socket.end();
} else if (!server.httpAllowHalfOpen) {
socket.end();
} else if (state.outgoing.length) {
state.outgoing[state.outgoing.length - 1]._last = true;
} else if (socket._httpMessage) {
socket._httpMessage._last = true;
} else if (socket.writable) {
} else {
socket.end();
}
}
Expand All @@ -628,6 +621,7 @@ function socketOnData(server, socket, parser, state, d) {

function onRequestTimeout(socket) {
socket[kRequestTimeout] = undefined;
// socketOnError has additional logic and will call socket.destroy(err).
ReflectApply(socketOnError, socket, [new ERR_HTTP_REQUEST_TIMEOUT()]);
}

Expand Down