GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: deflake test-http-keep-alive-empty-line · nodejs/node@4c48ec0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-http-keep-alive-empty-line.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-http-keep-alive-empty-line.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-keep-alive-empty-line.mjs
+15-10Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import assert from 'node:assert';
33
import { createServer } from 'node:http';
44
import { connect } from 'node:net';
55

6+
// This test ensures that data like an empty line (`\r\n`) recevied by the
7+
// server after a request, does not reset the keep-alive timeout. See
8+
// https://github.com/nodejs/node/issues/58140.
9+
610
const server = createServer({
711
connectionsCheckingInterval: 100,
812
headersTimeout: 100,
@@ -28,23 +32,24 @@ server.listen(0, () => {
2832
'\r\n'
2933
);
3034

31-
setTimeout(() => {
32-
client.write('\r\n');
33-
}, 100);
34-
35-
let responseBuffer = '';
35+
let response = '';
36+
let responseReceived = false;
3637

38+
client.setEncoding('utf-8');
3739
client.on('data', (chunk) => {
38-
responseBuffer += chunk.toString();
40+
response += chunk;
3941

4042
// Check if we've received the full header (ending with \r\n\r\n)
41-
if (responseBuffer.includes('\r\n\r\n')) {
42-
const statusLine = responseBuffer.split('\r\n')[0];
43+
if (response.includes('\r\n\r\n')) {
44+
responseReceived = true;
45+
const statusLine = response.split('\r\n')[0];
4346
const status = statusLine.split(' ')[1];
4447
assert.strictEqual(status, '404');
45-
client.end();
48+
client.write('\r\n');
4649
}
4750
});
48-
client.on('end', common.mustCall());
51+
client.on('end', common.mustCall(() => {
52+
assert.ok(responseReceived);
53+
}));
4954
});
5055
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.