2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-05-29 03:06:56 -04:00
|
|
|
require('../common');
|
2016-12-30 18:38:06 -05:00
|
|
|
const assert = require('assert');
|
|
|
|
const http = require('http');
|
2012-05-07 22:49:10 +02:00
|
|
|
|
|
|
|
var options = {
|
|
|
|
method: 'GET',
|
2016-05-29 03:06:56 -04:00
|
|
|
port: undefined,
|
2012-05-07 22:49:10 +02:00
|
|
|
host: '127.0.0.1',
|
|
|
|
path: '/'
|
|
|
|
};
|
|
|
|
|
|
|
|
var server = http.createServer(function(req, res) {
|
|
|
|
// this space intentionally left blank
|
|
|
|
});
|
|
|
|
|
2016-05-29 03:06:56 -04:00
|
|
|
server.listen(0, options.host, function() {
|
|
|
|
options.port = this.address().port;
|
2012-05-07 22:49:10 +02:00
|
|
|
var req = http.request(options, function(res) {
|
|
|
|
// this space intentionally left blank
|
|
|
|
});
|
|
|
|
req.on('close', function() {
|
|
|
|
server.close();
|
|
|
|
});
|
|
|
|
function destroy() {
|
|
|
|
req.destroy();
|
|
|
|
}
|
2015-05-13 21:25:57 -05:00
|
|
|
var s = req.setTimeout(1, destroy);
|
|
|
|
assert.ok(s instanceof http.ClientRequest);
|
2012-05-07 22:49:10 +02:00
|
|
|
req.on('error', destroy);
|
|
|
|
req.end();
|
|
|
|
});
|