| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent def681a commit 54aafa1
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,8 +4,21 @@ const common = require('../common'); | |||
| 4 | 4 | const http = require('http'); | |
| 5 | 5 | const assert = require('assert'); | |
| 6 | 6 | ||
| 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. | ||
| 8 | 10 | 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', | ||
| 9 | 22 | 'retry-after', | |
| 10 | 23 | 'etag', | |
| 11 | 24 | 'last-modified', | |
@@ -17,12 +30,14 @@ const norepeat = [ | |||
| 17 | 30 | const server = http.createServer(function(req, res) { | |
| 18 | 31 | var num = req.headers['x-num']; | |
| 19 | 32 | if (num == 1) { | |
| 33 | + res.setHeader('content-length', [1, 2]); | ||
| 20 | 34 | for (const name of norepeat) { | |
| 21 | 35 | res.setHeader(name, ['A', 'B']); | |
| 22 | 36 | } | |
| 23 | 37 | res.setHeader('X-A', ['A', 'B']); | |
| 24 | 38 | } else if (num == 2) { | |
| 25 | 39 | const headers = {}; | |
| 40 | + headers['content-length'] = [1, 2]; | ||
| 26 | 41 | for (const name of norepeat) { | |
| 27 | 42 | headers[name] = ['A', 'B']; | |
| 28 | 43 | } | |
@@ -44,6 +59,7 @@ server.listen(common.PORT, common.mustCall(function() { | |||
| 44 | 59 | {port:common.PORT, headers:{'x-num': n}}, | |
| 45 | 60 | common.mustCall(function(res) { | |
| 46 | 61 | if (n == 2) server.close(); | |
| 62 | + assert.equal(res.headers['content-length'], 1); | ||
| 47 | 63 | for (const name of norepeat) { | |
| 48 | 64 | assert.equal(res.headers[name], 'A'); | |
| 49 | 65 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments