diff options
author | Hackzzila <admin@hackzzila.com> | 2018-04-24 19:37:43 -0500 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-04-29 17:03:16 +0200 |
commit | 564048dc2984c45884e5eb58c903f9a0ebe29ab4 (patch) | |
tree | 443c28793fbcc2bf4fedd00cbd6e161fb0675270 /test/parallel/test-http-correct-hostname.js | |
parent | 511230fdae1f61594808a8f547c7f3e5e46727ef (diff) | |
download | android-node-v8-564048dc2984c45884e5eb58c903f9a0ebe29ab4.tar.gz android-node-v8-564048dc2984c45884e5eb58c903f9a0ebe29ab4.tar.bz2 android-node-v8-564048dc2984c45884e5eb58c903f9a0ebe29ab4.zip |
http,https,tls: switch to WHATWG URL parser
This switches the url parser from `url.parse()` to the WHATWG URL
parser while keeping `url.parse()` as fallback.
Also add tests for invalid url deprecations and correct hostname
checks.
PR-URL: https://github.com/nodejs/node/pull/20270
Fixes: https://github.com/nodejs/node/issues/19468
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/parallel/test-http-correct-hostname.js')
-rw-r--r-- | test/parallel/test-http-correct-hostname.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/parallel/test-http-correct-hostname.js b/test/parallel/test-http-correct-hostname.js new file mode 100644 index 0000000000..b4279c1da4 --- /dev/null +++ b/test/parallel/test-http-correct-hostname.js @@ -0,0 +1,28 @@ +/* eslint-disable node-core/crypto-check */ +// Flags: --expose-internals +'use strict'; + +const common = require('../common'); +const assert = require('assert'); + +const { outHeadersKey } = require('internal/http'); + +const http = require('http'); +const modules = { http }; + +if (common.hasCrypto) { + const https = require('https'); + modules.https = https; +} + +Object.keys(modules).forEach((module) => { + const doNotCall = common.mustNotCall( + `${module}.request should not connect to ${module}://example.com%60x.example.com` + ); + const req = modules[module].request(`${module}://example.com%60x.example.com`, doNotCall); + assert.deepStrictEqual(req[outHeadersKey].host, [ + 'Host', + 'example.com`x.example.com', + ]); + req.abort(); +}); |