0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-http-request-agent.js
Ujjwal Sharma 580ad0157a
test: name test files appropriately
Rename the tests appropriately alongside mentioning the subsystem.
Also, make a few basic changes to make sure the test conforms
to the standard test structure.

This renames:
- test-regress-GH-1531
- test-regress-GH-2245
- test-regress-GH-3238
- test-regress-GH-3542
- test-regress-GH-3739
- test-regress-GH-4256

PR-URL: https://github.com/nodejs/node/pull/19212
Refs: https://github.com/nodejs/node/issues/19105
Refs: https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md#test-structure
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-11 04:17:42 +01:00

41 lines
975 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const fixtures = require('../common/fixtures');
// This test ensures that a http request callback is called when the agent
// option is set.
// See https://github.com/nodejs/node-v0.x-archive/issues/1531
const https = require('https');
const options = {
key: fixtures.readKey('agent1-key.pem'),
cert: fixtures.readKey('agent1-cert.pem')
};
const server = https.createServer(options, function(req, res) {
res.writeHead(200);
res.end('hello world\n');
});
server.listen(0, common.mustCall(function() {
console.error('listening');
https.get({
agent: false,
path: '/',
port: this.address().port,
rejectUnauthorized: false
}, common.mustCall(function(res) {
console.error(res.statusCode, res.headers);
res.resume();
server.close();
})).on('error', function(e) {
console.error(e.stack);
process.exit(1);
});
}));