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');
|
2013-03-21 21:38:30 +04:00
|
|
|
|
2016-12-30 18:38:06 -05:00
|
|
|
const http = require('http');
|
2013-03-21 21:38:30 +04:00
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
let serverRequests = 0;
|
|
|
|
let clientRequests = 0;
|
2013-03-21 21:38:30 +04:00
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const server = http.createServer(function(req, res) {
|
2013-03-21 21:38:30 +04:00
|
|
|
serverRequests++;
|
|
|
|
res.writeHead(200, {'Content-Type': 'text/plain'});
|
|
|
|
res.end('OK');
|
|
|
|
});
|
|
|
|
|
2016-05-29 03:06:56 -04:00
|
|
|
server.listen(0, function() {
|
2015-05-19 13:00:06 +02:00
|
|
|
function callback() {}
|
2013-03-21 21:38:30 +04:00
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const req = http.request({
|
2016-05-29 03:06:56 -04:00
|
|
|
port: this.address().port,
|
2013-03-21 21:38:30 +04:00
|
|
|
path: '/',
|
|
|
|
agent: false
|
|
|
|
}, function(res) {
|
|
|
|
req.clearTimeout(callback);
|
|
|
|
|
|
|
|
res.on('end', function() {
|
|
|
|
clientRequests++;
|
|
|
|
server.close();
|
2015-05-19 13:00:06 +02:00
|
|
|
});
|
2013-03-21 21:38:30 +04:00
|
|
|
|
|
|
|
res.resume();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Overflow signed int32
|
|
|
|
req.setTimeout(0xffffffff, callback);
|
|
|
|
req.end();
|
|
|
|
});
|
|
|
|
|
|
|
|
process.once('exit', function() {
|
2017-01-08 15:36:25 +00:00
|
|
|
assert.strictEqual(clientRequests, 1);
|
|
|
|
assert.strictEqual(serverRequests, 1);
|
2013-03-21 21:38:30 +04:00
|
|
|
});
|