mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
https: make https.get() accept a URL
https.get() now accepts either a URL (as a string) or an options object. Refs #2859. Fixes #3882.
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
var tls = require('tls');
|
||||
var http = require('http');
|
||||
var url = require('url');
|
||||
var inherits = require('util').inherits;
|
||||
|
||||
function Server(opts, requestListener) {
|
||||
@@ -88,6 +89,10 @@ exports.globalAgent = globalAgent;
|
||||
exports.Agent = Agent;
|
||||
|
||||
exports.request = function(options, cb) {
|
||||
if (typeof options === 'string') {
|
||||
options = url.parse(options);
|
||||
}
|
||||
|
||||
if (options.protocol && options.protocol !== 'https:') {
|
||||
throw new Error('Protocol:' + options.protocol + ' not supported.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user