Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 54aafa1

Browse filesBrowse files
benglrvagg
authored andcommitted
test: http complete list of non-concat headers
The original test was only testing some of the headers that shouldn't be concatenated as per lib/_http_incoming.js, so now the full list is there. 'content-length` gives a parse error if you set it to a string, so the test for that header uses numbers. PR-URL: #3930 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent def681a commit 54aafa1
Copy full SHA for 54aafa1

File tree

Expand file treeCollapse file tree

1 file changed

+17
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+17
-1
lines changed
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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.