public
Created

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
var http = require('http');
var assert = require('assert');
 
var options = {
method: 'GET',
port: 3000,
host: '127.0.0.1',
path: '/'
};
 
var server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Length':'2'});
setTimeout(function() { res.write('*'); res.end('*') }, 20);
});
 
server.listen(options.port, options.host, function() {
var req = http.request(options, onresponse);
var timeout = false;
req.setTimeout(10, function() {
timeout = true;
});
 
req.end();
 
function onresponse(res) {
assert.ok(!timeout, 'Ouch');
res.on('data', function(data) {
});
 
res.on('end', function() {
server.close();
});
}
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.