• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const assert = require('assert');
4const fixtures = require('../common/fixtures');
5
6if (!common.hasCrypto)
7  common.skip('missing crypto');
8const https = require('https');
9
10const options = {
11  key: fixtures.readKey('agent1-key.pem'),
12  cert: fixtures.readKey('agent1-cert.pem'),
13  ca: fixtures.readKey('ca1-cert.pem')
14};
15
16// Test providing both a url and options, with the options partially
17// replacing address and port portions of the URL provided.
18{
19  const server = https.createServer(
20    options,
21    common.mustCall((req, res) => {
22      assert.strictEqual(req.url, '/testpath');
23      res.end();
24      server.close();
25    })
26  );
27
28  server.listen(
29    0,
30    common.mustCall(() => {
31      https.get(
32        'https://example.com/testpath',
33
34        {
35          hostname: 'localhost',
36          port: server.address().port,
37          rejectUnauthorized: false
38        },
39
40        common.mustCall((res) => {
41          res.resume();
42        })
43      );
44    })
45  );
46}
47