Skip to content

Commit 54aafa1

Browse 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 <[email protected]>
1 parent def681a commit 54aafa1

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

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

+17-1
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)