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: refactor test-http-information-processing · nodejs/node@8bcbb8d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-http-information-processing.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-http-information-processing.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-information-processing.js
+12-15Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22
require('../common');
33
const assert = require('assert');
44
const http = require('http');
5-
const Countdown = require('../common/countdown');
65

7-
const test_res_body = 'other stuff!\n';
8-
const countdown = new Countdown(3, () => server.close());
6+
const testResBody = 'other stuff!\n';
7+
const kMessageCount = 2;
98

109
const server = http.createServer((req, res) => {
11-
console.error('Server sending informational message #1...');
12-
res.writeProcessing();
13-
console.error('Server sending informational message #2...');
14-
res.writeProcessing();
10+
for (let i = 0; i < kMessageCount; i++) {
11+
console.error(`Server sending informational message #${i}...`);
12+
res.writeProcessing();
13+
}
1514
console.error('Server sending full response...');
1615
res.writeHead(200, {
1716
'Content-Type': 'text/plain',
1817
'ABCD': '1'
1918
});
20-
res.end(test_res_body);
19+
res.end(testResBody);
2120
});
2221

2322
server.listen(0, function() {
@@ -29,24 +28,22 @@ server.listen(0, function() {
2928
console.error('Client sending request...');
3029

3130
let body = '';
31+
let infoCount = 0;
3232

33-
req.on('information', function(res) {
34-
console.error('Client got 102 Processing...');
35-
countdown.dec();
36-
});
33+
req.on('information', () => { infoCount++; });
3734

3835
req.on('response', function(res) {
3936
// Check that all 102 Processing received before full response received.
40-
assert.strictEqual(countdown.remaining, 1);
37+
assert.strictEqual(infoCount, kMessageCount);
4138
assert.strictEqual(res.statusCode, 200,
4239
`Final status code was ${res.statusCode}, not 200.`);
4340
res.setEncoding('utf8');
4441
res.on('data', function(chunk) { body += chunk; });
4542
res.on('end', function() {
4643
console.error('Got full response.');
47-
assert.strictEqual(body, test_res_body);
44+
assert.strictEqual(body, testResBody);
4845
assert.ok('abcd' in res.headers);
49-
countdown.dec();
46+
server.close();
5047
});
5148
});
5249
});

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.