mirror of https://github.com/nodejs/node.git
test: make HTTP/1.0 connection test more robust
Fixes: https://github.com/nodejs/node/issues/47200 Co-authored-by: Luigi Pinca <luigipinca@gmail.com> PR-URL: https://github.com/nodejs/node/pull/55959 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com>pull/55988/head
parent
1d0738a85e
commit
b6fe731c55
|
@ -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');
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue