url: allow use of URL with http.request and https.request

PR-URL: https://github.com/nodejs/node/pull/10638
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Michal Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
James M Snell authored and Italo A. Casas committed 2017-01-30 12:08:37 -05:00
1 parent 3adda4b2ad
commit 2f9fdc454f
6 files changed
+61 -5

No files matched your search

+3
View File
@@ -8,6 +8,7 @@ const http = require('http');
const util = require('util');
const inherits = util.inherits;
const debug = util.debuglog('https');
const urlToOptions = require('internal/url').urlToOptions;
function Server(opts, requestListener) {
if (!(this instanceof Server)) return new Server(opts, requestListener);
@@ -196,6 +197,8 @@ exports.request = function request(options, cb) {
if (!options.hostname) {
throw new Error('Unable to determine the domain name');
}
} else if (options instanceof url.URL) {
options = urlToOptions(options);
} else {
options = util._extend({}, options);
}