Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
http: fix free http-parser too early
Browse files Browse the repository at this point in the history
when the status code is 100 (Continue).

Fixes #2636.
  • Loading branch information
koichik committed Jan 30, 2012
1 parent b221fe9 commit 3fd13c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,11 @@ ClientRequest.prototype.onSocket = function(socket) {
socket.destroy();
}
freeParser();
} else if (parser.incoming && parser.incoming.complete) {
} else if (parser.incoming && parser.incoming.complete &&
// When the status code is 100 (Continue), the server will
// send a final response after this client sends a request
// body. So, we must not free the parser.
parser.incoming.statusCode !== 100) {
freeParser();
}
};
Expand Down
4 changes: 3 additions & 1 deletion test/simple/test-http-expect-continue.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ server.on('checkContinue', function(req, res) {
common.debug('Server got Expect: 100-continue...');
res.writeContinue();
sent_continue = true;
handler(req, res);
setTimeout(function() {
handler(req, res);
}, 100);
});
server.listen(common.PORT);

Expand Down

0 comments on commit 3fd13c6

Please sign in to comment.