mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -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
@@ -12,6 +12,8 @@ if (!common.hasCrypto) {
|
||||
const https = require('https');
|
||||
|
||||
const fs = require('fs');
|
||||
const url = require('url');
|
||||
const URL = url.URL;
|
||||
|
||||
var options = {
|
||||
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
||||
@@ -25,8 +27,11 @@ var server = https.createServer(options, common.mustCall(function(req, res) {
|
||||
res.write('hello\n');
|
||||
res.end();
|
||||
server.close();
|
||||
}));
|
||||
}, 3));
|
||||
|
||||
server.listen(0, function() {
|
||||
https.get(`https://127.0.0.1:${this.address().port}/foo?bar`);
|
||||
const u = `https://127.0.0.1:${this.address().port}/foo?bar`;
|
||||
https.get(u);
|
||||
https.get(url.parse(u));
|
||||
https.get(new URL(u));
|
||||
});
|
||||
Reference in new issue
Block a user