test: check result as early as possible

PR-URL: https://github.com/nodejs/io.js/pull/2007
Reviewed-By: Rod Vagg <rod@vagg.org>
pull/1824/merge
Rich Trott 2015-06-17 22:14:22 -07:00
parent 8ac50819b6
commit 3ba4f71fc4
1 changed files with 2 additions and 4 deletions

View File

@ -47,12 +47,10 @@ server.listen(common.PORT, function() {
var s = fs.createWriteStream(common.tmpDir + '/' + x + '.jpg');
res.pipe(s);
// TODO there should be a callback to pipe() that will allow
// us to get a callback when the pipe is finished.
res.on('end', function() {
s.on('finish', function() {
console.error('done ' + x);
if (++responses == total) {
s.on('close', checkFiles);
checkFiles();
}
});
}).on('error', function(e) {