Skip to content
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

test: make HTTP/1.0 connection test more robust #55959

Merged
merged 1 commit into from
Nov 24, 2024
Merged
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
test: make HTTP/1.0 connection test more robust
Fixes: #47200

Co-authored-by: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
FliegendeWurst and lpinca committed Nov 23, 2024
commit 401f5f22154d64cd81eaf2a5451ae72a9eaed510
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ const server = http.createServer(function(request, response) {
// For HTTP/1.0, the connection should be closed after the response automatically.
response.removeHeader('connection');

if (request.httpVersion === '1.0') {
const socket = request.socket;
response.on('finish', common.mustCall(function() {
assert.ok(socket.writableEnded);
}));
}

response.end('beep boop\n');
});

Expand Down Expand Up @@ -50,9 +57,7 @@ function makeHttp10Request(cb) {
'\r\n');
socket.resume(); // Ignore the response itself

setTimeout(function() {
cb(socket);
}, common.platformTimeout(50));
socket.on('close', cb);
});
}

Expand All @@ -62,9 +67,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
Loading