mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
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:
1 parent
3adda4b2ad
commit
2f9fdc454f
6 files changed
+61
-5
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user