Skip to content

Commit

Permalink
test: make HTTP/1.0 connection test more robust
Browse files Browse the repository at this point in the history
Fixes: nodejs#47200

Co-authored-by: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
FliegendeWurst and lpinca committed Nov 23, 2024
1 parent 02921e1 commit 4c41b60
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ function makeHttp10Request(cb) {
'\r\n');
socket.resume(); // Ignore the response itself

setTimeout(function() {
cb(socket);
}, common.platformTimeout(50));
// Invoke the callback when the socket closes. The server should close it
// immediately after sending the response.
socket.on('close', cb);
// If the socket is not closed, the test will fail with a timeout.
});
}

Expand All @@ -62,9 +63,7 @@ server.listen(0, function() {
// Both HTTP/1.1 requests should have used the same socket:
assert.strictEqual(firstSocket, secondSocket);

makeHttp10Request(function(socket) {
// The server should have immediately closed the HTTP/1.0 socket:
assert.strictEqual(socket.closed, true);
makeHttp10Request(function() {
server.close();
});
});
Expand Down

0 comments on commit 4c41b60

Please sign in to comment.