From 470c8baefe3f407a89ef640e09d0ab409b731089 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Thu, 19 Nov 2015 16:28:45 -0800 Subject: [PATCH] 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. --- .../test-http-response-multiheaders.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-http-response-multiheaders.js b/test/parallel/test-http-response-multiheaders.js index 572ce2e128bf29..c45d2aed674c14 100644 --- a/test/parallel/test-http-response-multiheaders.js +++ b/test/parallel/test-http-response-multiheaders.js @@ -4,8 +4,21 @@ const common = require('../common'); const http = require('http'); const assert = require('assert'); -// Test that certain response header fields do not repeat +// Test that certain response header fields do not repeat. +// 'content-length' should also be in this list, but it needs +// a numeric header, so it's tested slightly differently. const norepeat = [ + 'content-type', + 'user-agent', + 'referer', + 'host', + 'authorization', + 'proxy-authorization', + 'if-modified-since', + 'if-unmodified-since', + 'from', + 'location', + 'max-forwards', 'retry-after', 'etag', 'last-modified', @@ -17,12 +30,14 @@ const norepeat = [ const server = http.createServer(function(req, res) { var num = req.headers['x-num']; if (num == 1) { + res.setHeader('content-length', [1, 2]); for (const name of norepeat) { res.setHeader(name, ['A', 'B']); } res.setHeader('X-A', ['A', 'B']); } else if (num == 2) { const headers = {}; + headers['content-length'] = [1, 2]; for (const name of norepeat) { headers[name] = ['A', 'B']; } @@ -44,6 +59,7 @@ server.listen(common.PORT, common.mustCall(function() { {port:common.PORT, headers:{'x-num': n}}, common.mustCall(function(res) { if (n == 2) server.close(); + assert.equal(res.headers['content-length'], 1); for (const name of norepeat) { assert.equal(res.headers[name], 'A'); }