2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-07-18 22:33:42 +02:00
|
|
|
const common = require('../common');
|
2012-08-30 15:14:37 +02:00
|
|
|
// disable strict server certificate validation by the client
|
|
|
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
|
|
|
2016-12-31 00:38:06 +01:00
|
|
|
const assert = require('assert');
|
2015-03-04 02:11:21 +01:00
|
|
|
|
|
|
|
if (!common.hasCrypto) {
|
2016-05-11 21:34:52 +02:00
|
|
|
common.skip('missing crypto');
|
2015-07-07 17:25:55 +02:00
|
|
|
return;
|
2015-03-04 02:11:21 +01:00
|
|
|
}
|
2016-12-31 00:38:06 +01:00
|
|
|
const https = require('https');
|
2015-03-04 02:11:21 +01:00
|
|
|
|
2016-12-31 00:38:06 +01:00
|
|
|
const fs = require('fs');
|
2017-01-05 19:25:46 +01:00
|
|
|
const url = require('url');
|
|
|
|
const URL = url.URL;
|
2012-08-18 07:18:02 +02:00
|
|
|
|
2017-01-08 14:19:00 +01:00
|
|
|
const options = {
|
2012-08-18 07:18:02 +02:00
|
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
|
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
|
|
|
|
};
|
|
|
|
|
2017-01-08 14:19:00 +01:00
|
|
|
const server = https.createServer(options, common.mustCall(function(req, res) {
|
2017-01-08 16:36:25 +01:00
|
|
|
assert.strictEqual('GET', req.method);
|
|
|
|
assert.strictEqual('/foo?bar', req.url);
|
2012-08-18 07:18:02 +02:00
|
|
|
res.writeHead(200, {'Content-Type': 'text/plain'});
|
|
|
|
res.write('hello\n');
|
|
|
|
res.end();
|
|
|
|
server.close();
|
2017-01-05 19:25:46 +01:00
|
|
|
}, 3));
|
2012-08-18 07:18:02 +02:00
|
|
|
|
2016-05-29 09:06:56 +02:00
|
|
|
server.listen(0, function() {
|
2017-01-05 19:25:46 +01:00
|
|
|
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));
|
2012-08-18 07:18:02 +02:00
|
|
|
});
|