Skip to content

Commit 1a78bde

Browse files
FliegendeWurstlpinca
authored andcommitted
test: make HTTP/1.0 connection test more robust
Fixes: #47200 Co-authored-by: Luigi Pinca <[email protected]> PR-URL: #55959 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Jason Zhang <[email protected]>
1 parent f61dcc4 commit 1a78bde

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

‎test/parallel/test-http-remove-connection-header-persists-connection.js‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ const server = http.createServer(function(request, response){
1010
// For HTTP/1.0, the connection should be closed after the response automatically.
1111
response.removeHeader('connection');
1212

13+
if(request.httpVersion==='1.0'){
14+
constsocket=request.socket;
15+
response.on('finish',common.mustCall(function(){
16+
assert.ok(socket.writableEnded);
17+
}));
18+
}
19+
1320
response.end('beep boop\n');
1421
});
1522

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

53-
setTimeout(function(){
54-
cb(socket);
55-
},common.platformTimeout(50));
60+
socket.on('close',cb);
5661
});
5762
}
5863

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

65-
makeHttp10Request(function(socket){
66-
// The server should have immediately closed the HTTP/1.0 socket:
67-
assert.strictEqual(socket.closed,true);
70+
makeHttp10Request(function(){
6871
server.close();
6972
});
7073
});

0 commit comments

Comments
(0)