-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https: allow url and options to be passed to https.request
PR-URL: #22003 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Backport-PR-URL: #21880 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
- Loading branch information
Showing
2 changed files
with
65 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const https = require('https'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const options = { | ||
key: fixtures.readKey('agent1-key.pem'), | ||
cert: fixtures.readKey('agent1-cert.pem'), | ||
ca: fixtures.readKey('ca1-cert.pem') | ||
}; | ||
|
||
// Test providing both a url and options, with the options partially | ||
// replacing address and port portions of the URL provided. | ||
{ | ||
const server = https.createServer( | ||
options, | ||
common.mustCall((req, res) => { | ||
assert.strictEqual(req.url, '/testpath'); | ||
res.end(); | ||
server.close(); | ||
}) | ||
); | ||
|
||
server.listen( | ||
0, | ||
common.mustCall(() => { | ||
https.get( | ||
'https://example.com/testpath', | ||
|
||
{ | ||
hostname: 'localhost', | ||
port: server.address().port, | ||
rejectUnauthorized: false | ||
}, | ||
|
||
common.mustCall((res) => { | ||
res.resume(); | ||
}) | ||
); | ||
}) | ||
); | ||
} |