Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1a78bde

Browse filesBrowse files
FliegendeWurstlpinca
authored andcommitted
test: make HTTP/1.0 connection test more robust
Fixes: #47200 Co-authored-by: Luigi Pinca <luigipinca@gmail.com> PR-URL: #55959 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com>
1 parent f61dcc4 commit 1a78bde
Copy full SHA for 1a78bde

File tree

Expand file treeCollapse file tree

1 file changed

+9
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-6
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-http-remove-connection-header-persists-connection.js
+9-6Lines 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+
const socket = 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.