diff options
author | Weijia Wang <381152119@qq.com> | 2017-08-10 18:58:22 +0800 |
---|---|---|
committer | Refael Ackermann <refack@gmail.com> | 2017-08-14 17:19:19 -0400 |
commit | 11a2ca29babcb35132e7d93244b69c544d52dfe4 (patch) | |
tree | a7372ad1c4dfc4300d8a050c8f1fe3cccdadc3b4 /test/parallel/test-http-response-splitting.js | |
parent | 28a47aa1bbd4d278293fda2bb3f2df836d743816 (diff) | |
download | node-new-11a2ca29babcb35132e7d93244b69c544d52dfe4.tar.gz |
errors: migrate _http_outgoing
PR-URL: https://github.com/nodejs/node/pull/14735
Refs: https://github.com/nodejs/node/issues/11273
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'test/parallel/test-http-response-splitting.js')
-rw-r--r-- | test/parallel/test-http-response-splitting.js | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/test/parallel/test-http-response-splitting.js b/test/parallel/test-http-response-splitting.js index b14d59e59c..bf483b53e3 100644 --- a/test/parallel/test-http-response-splitting.js +++ b/test/parallel/test-http-response-splitting.js @@ -1,6 +1,6 @@ 'use strict'; -require('../common'); +const common = require('../common'); const http = require('http'); const net = require('net'); const url = require('url'); @@ -19,23 +19,29 @@ const y = 'foo⠊Set-Cookie: foo=bar'; let count = 0; -function test(res, code, header) { - assert.throws(() => { - res.writeHead(code, header); - }, /^TypeError: The header content contains invalid characters$/); +function test(res, code, key, value) { + const header = { [key]: value }; + common.expectsError( + () => res.writeHead(code, header), + { + code: 'ERR_INVALID_CHAR', + type: TypeError, + message: `Invalid character in header content ["${key}"]` + } + ); } const server = http.createServer((req, res) => { switch (count++) { case 0: const loc = url.parse(req.url, true).query.lang; - test(res, 302, { Location: `/foo?lang=${loc}` }); + test(res, 302, 'Location', `/foo?lang=${loc}`); break; case 1: - test(res, 200, { 'foo': x }); + test(res, 200, 'foo', x); break; case 2: - test(res, 200, { 'foo': y }); + test(res, 200, 'foo', y); break; default: assert.fail('should not get to here.'); |