url: expose urlToHttpOptions utility

PR-URL: https://github.com/nodejs/node/pull/35960
Fixes: https://github.com/nodejs/node/issues/34349
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
zhangyongsheng authored and Ruy Adorno committed 2021-01-21 17:48:10 -05:00
1 parent 3ea37c2d67
commit 64fed319ef
7 files changed
+95 -46

No files matched your search

+3 -3
View File
@@ -48,7 +48,7 @@ const { ClientRequest } = require('_http_client');
let debug = require('internal/util/debuglog').debuglog('https', (fn) => {
debug = fn;
});
const { URL, urlToOptions, searchParamsSymbol } = require('internal/url');
const { URL, urlToHttpOptions, searchParamsSymbol } = require('internal/url');
const { IncomingMessage, ServerResponse } = require('http');
const { kIncomingMessage } = require('_http_common');
@@ -303,7 +303,7 @@ function request(...args) {
if (typeof args[0] === 'string') {
const urlStr = ArrayPrototypeShift(args);
try {
options = urlToOptions(new URL(urlStr));
options = urlToHttpOptions(new URL(urlStr));
} catch (err) {
options = url.parse(urlStr);
if (!options.hostname) {
@@ -320,7 +320,7 @@ function request(...args) {
} else if (args[0] && args[0][searchParamsSymbol] &&
args[0][searchParamsSymbol][searchParamsSymbol]) {
// url.URL instance
options = urlToOptions(ArrayPrototypeShift(args));
options = urlToHttpOptions(ArrayPrototypeShift(args));
}
if (args[0] && typeof args[0] !== 'function') {