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: http complete list of non-concat headers · nodejs/node@174d4e4

File tree

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

‎test/parallel/test-http-response-multiheaders.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-response-multiheaders.js
+17-1Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@ const common = require('../common');
44
const http = require('http');
55
const assert = require('assert');
66

7-
// Test that certain response header fields do not repeat
7+
// Test that certain response header fields do not repeat.
8+
// 'content-length' should also be in this list, but it needs
9+
// a numeric value, so it's tested slightly differently.
810
const norepeat = [
11+
'content-type',
12+
'user-agent',
13+
'referer',
14+
'host',
15+
'authorization',
16+
'proxy-authorization',
17+
'if-modified-since',
18+
'if-unmodified-since',
19+
'from',
20+
'location',
21+
'max-forwards',
922
'retry-after',
1023
'etag',
1124
'last-modified',
@@ -17,12 +30,14 @@ const norepeat = [
1730
const server = http.createServer(function(req, res) {
1831
var num = req.headers['x-num'];
1932
if (num == 1) {
33+
res.setHeader('content-length', [1, 2]);
2034
for (const name of norepeat) {
2135
res.setHeader(name, ['A', 'B']);
2236
}
2337
res.setHeader('X-A', ['A', 'B']);
2438
} else if (num == 2) {
2539
const headers = {};
40+
headers['content-length'] = [1, 2];
2641
for (const name of norepeat) {
2742
headers[name] = ['A', 'B'];
2843
}
@@ -44,6 +59,7 @@ server.listen(common.PORT, common.mustCall(function() {
4459
{port:common.PORT, headers:{'x-num': n}},
4560
common.mustCall(function(res) {
4661
if (n == 2) server.close();
62+
assert.equal(res.headers['content-length'], 1);
4763
for (const name of norepeat) {
4864
assert.equal(res.headers[name], 'A');
4965
}

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.