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-remove-header-stays-removed · nodejs/node@82c4022

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-http-remove-header-stays-removed.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-http-remove-header-stays-removed.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-remove-header-stays-removed.js
+16-17Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ const assert = require('assert');
2525

2626
const http = require('http');
2727

28-
const server = http.createServer(function(request, response) {
28+
const server = http.createServer(common.mustCall(function(request, response) {
29+
const socket = response.socket;
30+
2931
// Removed headers should stay removed, even if node automatically adds them
3032
// to the output:
3133
response.removeHeader('connection');
@@ -36,32 +38,29 @@ const server = http.createServer(function(request, response) {
3638
response.removeHeader('date');
3739
response.setHeader('date', 'coffee o clock');
3840

39-
response.end('beep boop\n');
40-
});
41-
42-
let response = '';
41+
response.on('finish', common.mustCall(function() {
42+
// The socket should be closed immediately, with no keep-alive, because
43+
// no content-length or transfer-encoding are used.
44+
assert.strictEqual(socket.writableEnded, true);
45+
}));
4346

44-
process.on('exit', function() {
45-
assert.strictEqual(response, 'beep boop\n');
46-
console.log('ok');
47-
});
47+
response.end('beep boop\n');
48+
}));
4849

4950
server.listen(0, function() {
5051
http.get({ port: this.address().port }, function(res) {
5152
assert.strictEqual(res.statusCode, 200);
5253
assert.deepStrictEqual(res.headers, { date: 'coffee o clock' });
5354

55+
let response = '';
5456
res.setEncoding('ascii');
5557
res.on('data', function(chunk) {
5658
response += chunk;
57-
if (response === 'beep boop\n') {
58-
setTimeout(function() {
59-
// The socket should be closed immediately, with no keep-alive, because
60-
// no content-length or transfer-encoding are used:
61-
assert.strictEqual(res.socket.closed, true);
62-
server.close();
63-
}, common.platformTimeout(15));
64-
}
59+
});
60+
61+
res.on('end', function() {
62+
assert.strictEqual(response, 'beep boop\n');
63+
server.close();
6564
});
6665
});
6766
});

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.