Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix test
  • Loading branch information
islandryu committed May 7, 2025
commit 350b680fc0868baa857d5aaa6b8f066e10effe4e
45 changes: 27 additions & 18 deletions test/parallel/test-http-keep-alive-empty-line.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,35 @@ const server = createServer({
}));
});

server.listen(0);
server.listen(0, () => {
const client = connect({
host: 'localhost',
port: server.address().port,
}, () => {
client.write(
'GET / HTTP/1.1\r\n' +
'Host: localhost:3000\r\n' +
'Content-Length: 0\r\n' +
'\r\n'
);

const client = connect({
host: 'localhost',
port: server.address().port,
}, () => {
client.write(
'GET / HTTP/1.1\r\n' +
'Host: localhost:3000\r\n' +
'Content-Length: 0\r\n' +
'\r\n'
);
setTimeout(() => {
client.write('\r\n');
}, 100);

setTimeout(() => {
client.write('\r\n');
}, 100);
let responseBuffer = '';

client.on('data', (data) => {
const status = data.toString().split(' ')[1];
assert.strictEqual(status, '404');
client.on('data', (chunk) => {
responseBuffer += chunk.toString();

// Check if we've received the full header (ending with \r\n\r\n)
if (responseBuffer.includes('\r\n\r\n')) {
const statusLine = responseBuffer.split('\r\n')[0];
const status = statusLine.split(' ')[1];
assert.strictEqual(status, '404');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been flaking the CI for over a month #59577

client.end();
}
});
client.on('end', common.mustCall());
});
client.on('end', common.mustCall());
});
Loading