Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

http: fix free http-parser too early

when the response code is 100 (Continue).

Fixes #2636.
  • Loading branch information...
commit f36b0af30433d0f2f8a6c3710db36c9ebc9f8379 1 parent ca4b91a
@koichik authored
Showing with 8 additions and 2 deletions.
  1. +5 −1 lib/http.js
  2. +3 −1 test/simple/test-http-expect-continue.js
View
6 lib/http.js
@@ -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();
}
};
View
4 test/simple/test-http-expect-continue.js
@@ -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);

0 comments on commit f36b0af

Please sign in to comment.
Something went wrong with that request. Please try again.