Last active
December 24, 2015 15:19
-
-
Save tjfontaine/6819327 to your computer and use it in GitHub Desktop.
This file contains 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 common = require('../common') | |
var spawn = require('child_process').execFile; | |
var http = require('http'); | |
var TOTAL_BYTES = 100 * 1024 * 1024; | |
if (process.argv[2] === 'child') { | |
var seen = 0; | |
http.get({ | |
hostname: '127.0.0.1', | |
port: common.PORT, | |
path: '/', | |
}, function (res) { | |
console.log('%d\ns', res.statusCode, JSON.stringify(res.headers, null, 2)); | |
res.on('data', function (chunk) { | |
seen += chunk.length; | |
console.error('chunk received: %d', chunk.length); | |
res.pause(); | |
setImmediate(function() { | |
console.log('timeout'); | |
console.log(process._getActiveRequests()); | |
console.log(process._getActiveHandles()); | |
}); | |
}); | |
res.once('end', function () { | |
console.error('done'); | |
}); | |
}); | |
} else { | |
var buff = new Buffer(TOTAL_BYTES); | |
var server = http.createServer(function(req, res) { | |
console.log('sending', buff.length); | |
res.end(buff); | |
}).listen(common.PORT); | |
var child = spawn(process.execPath, | |
[process.argv[1], 'child'], | |
{ env: { NODE_DEBUG: 'http' } } | |
); | |
child.on('close', function() { | |
console.log('closing server'); | |
server.close(); | |
}); | |
child.stderr.pipe(process.stderr); | |
child.stdout.pipe(process.stdout); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment