Skip to content

Instantly share code, notes, and snippets.

@s3u
Created May 20, 2012 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s3u/2759844 to your computer and use it in GitHub Desktop.
Save s3u/2759844 to your computer and use it in GitHub Desktop.
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();
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment