11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ciif (!common.hasCrypto)
51cb0ef41Sopenharmony_ci  common.skip('missing crypto');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci// This test ensures that a http request callback is called when the agent
101cb0ef41Sopenharmony_ci// option is set.
111cb0ef41Sopenharmony_ci// See https://github.com/nodejs/node-v0.x-archive/issues/1531
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciconst https = require('https');
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciconst options = {
161cb0ef41Sopenharmony_ci  key: fixtures.readKey('agent1-key.pem'),
171cb0ef41Sopenharmony_ci  cert: fixtures.readKey('agent1-cert.pem')
181cb0ef41Sopenharmony_ci};
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ciconst server = https.createServer(options, function(req, res) {
211cb0ef41Sopenharmony_ci  res.writeHead(200);
221cb0ef41Sopenharmony_ci  res.end('hello world\n');
231cb0ef41Sopenharmony_ci});
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(function() {
261cb0ef41Sopenharmony_ci  console.error('listening');
271cb0ef41Sopenharmony_ci  https.get({
281cb0ef41Sopenharmony_ci    agent: false,
291cb0ef41Sopenharmony_ci    path: '/',
301cb0ef41Sopenharmony_ci    port: this.address().port,
311cb0ef41Sopenharmony_ci    rejectUnauthorized: false
321cb0ef41Sopenharmony_ci  }, common.mustCall(function(res) {
331cb0ef41Sopenharmony_ci    console.error(res.statusCode, res.headers);
341cb0ef41Sopenharmony_ci    res.resume();
351cb0ef41Sopenharmony_ci    server.close();
361cb0ef41Sopenharmony_ci  })).on('error', function(e) {
371cb0ef41Sopenharmony_ci    console.error(e);
381cb0ef41Sopenharmony_ci    process.exit(1);
391cb0ef41Sopenharmony_ci  });
401cb0ef41Sopenharmony_ci}));
41