Created
May 20, 2012 22:57
-
-
Save s3u/2759844 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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