Skip to content

Commit e078758

Browse files
test: make HTTP/1.0 connection test more robust
Fixes: nodejs#47200 Co-authored-by: Luigi Pinca <[email protected]>
1 parent 02921e1 commit e078758

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

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

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const common = require('../common');
2+
require('../common');
33
const assert = require('assert');
44

55
const net = require('net');
@@ -50,9 +50,10 @@ function makeHttp10Request(cb) {
5050
'\r\n');
5151
socket.resume(); // Ignore the response itself
5252

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

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

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

0 commit comments

Comments
 (0)