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: revise test-http-client-default-headers-exist · nodejs/node@565f0f7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-http-client-default-headers-exist.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-http-client-default-headers-exist.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-client-default-headers-exist.js
+7-12Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
const common = require('../common');
2424
const assert = require('assert');
2525
const http = require('http');
26-
const Countdown = require('../common/countdown');
26+
27+
const { once } = require('events');
2728

2829
const expectedHeaders = {
2930
'DELETE': ['host', 'connection'],
@@ -37,10 +38,6 @@ const expectedHeaders = {
3738

3839
const expectedMethods = Object.keys(expectedHeaders);
3940

40-
const countdown =
41-
new Countdown(expectedMethods.length,
42-
common.mustCall(() => server.close()));
43-
4441
const server = http.createServer(common.mustCall((req, res) => {
4542
res.end();
4643

@@ -49,9 +46,8 @@ const server = http.createServer(common.mustCall((req, res) => {
4946

5047
const requestHeaders = Object.keys(req.headers);
5148
requestHeaders.forEach((header) => {
52-
assert.strictEqual(
49+
assert.ok(
5350
expectedHeaders[req.method].includes(header.toLowerCase()),
54-
true,
5551
`${header} should not exist for method ${req.method}`
5652
);
5753
});
@@ -61,15 +57,14 @@ const server = http.createServer(common.mustCall((req, res) => {
6157
expectedHeaders[req.method].length,
6258
`some headers were missing for method: ${req.method}`
6359
);
64-
65-
countdown.dec();
6660
}, expectedMethods.length));
6761

6862
server.listen(0, common.mustCall(() => {
69-
expectedMethods.forEach((method) => {
70-
http.request({
63+
Promise.all(expectedMethods.map(async (method) => {
64+
const request = http.request({
7165
method: method,
7266
port: server.address().port
7367
}).end();
74-
});
68+
return once(request, 'response');
69+
})).then(common.mustCall(() => { server.close(); }));
7570
}));

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.