2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-07-15 15:43:24 -04:00
|
|
|
const common = require('../common');
|
2016-12-30 18:38:06 -05:00
|
|
|
const http = require('http');
|
|
|
|
const url = require('url');
|
2014-03-24 12:59:31 -10:00
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const server = http.createServer(common.mustCall(function(req, res) {
|
2014-03-24 12:59:31 -10:00
|
|
|
res.end();
|
2016-07-15 15:43:24 -04:00
|
|
|
})).listen(0, '127.0.0.1', common.mustCall(function() {
|
2017-01-08 13:19:00 +00:00
|
|
|
const opts = url.parse(`http://127.0.0.1:${this.address().port}/`);
|
2014-03-24 12:59:31 -10:00
|
|
|
|
|
|
|
// remove the `protocol` field… the `http` module should fall back
|
|
|
|
// to "http:", as defined by the global, default `http.Agent` instance.
|
|
|
|
opts.agent = new http.Agent();
|
|
|
|
opts.agent.protocol = null;
|
|
|
|
|
2016-07-15 15:43:24 -04:00
|
|
|
http.get(opts, common.mustCall(function(res) {
|
2014-03-24 12:59:31 -10:00
|
|
|
res.resume();
|
|
|
|
server.close();
|
2016-07-15 15:43:24 -04:00
|
|
|
}));
|
|
|
|
}));
|