Last active
August 29, 2015 14:05
-
-
Save dead-horse/c7030afa663fee61028b to your computer and use it in GitHub Desktop.
pipe bug in node 0.10.30
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 http = require('http'); | |
var fs = require('fs'); | |
var path = require('path'); | |
var tmp = path.join(__dirname, 't.tgz'); | |
var opts = { | |
hostname: 'registry.npmjs.com', | |
method: 'GET', | |
port: 80, | |
path: '/cutter/-/cutter-0.0.3.tgz', | |
headers: { | |
Connection: 'keep-alive' | |
} | |
} | |
http.request(opts, function (res) { | |
console.log('connection: %s', res.headers.connection); | |
res.resume(); | |
res.pause(); | |
setTimeout(function () { | |
var tarball = fs.createWriteStream(tmp, { mode: 420 }) | |
tarball.on('finish', function () { | |
console.log('tarball finish'); | |
}) | |
res.on('data', function (data) { | |
console.log('res on data: %s', data.length); | |
}) | |
res.on('end', function (d) { | |
console.log('res end'); | |
}) | |
res.pipe(tarball); | |
res.resume(); | |
}, 1000); | |
}).end(); | |
// output: | |
// connection: keep-alive | |
// res on data: 3144 | |
// res end | |
// tarball finish |
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 http = require('http'); | |
var fs = require('fs'); | |
var path = require('path'); | |
var tmp = path.join(__dirname, 't.tgz'); | |
var opts = { | |
hostname: 'registry.npmjs.com', | |
method: 'GET', | |
port: 80, | |
path: '/cutter/-/cutter-0.0.3.tgz', | |
headers: { | |
Connection: 'keep-alive' | |
} | |
} | |
http.request(opts, function (res) { | |
console.log('connection: %s', res.headers.connection); | |
res.resume(); | |
res.pause(); | |
var tarball = fs.createWriteStream(tmp, { mode: 420 }) | |
tarball.on('finish', function () { | |
console.log('tarball finish'); | |
}) | |
res.on('data', function (data) { | |
console.log('res on data: %s', data.length); | |
}) | |
res.on('end', function (d) { | |
console.log('res end'); | |
}) | |
res.pipe(tarball); | |
res.resume(); | |
}).end(); | |
// output: | |
// connection: keep-alive | |
// res on data: 3144 | |
// res end | |
// tarball finish | |
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 http = require('http'); | |
var fs = require('fs'); | |
var path = require('path'); | |
var tmp = path.join(__dirname, 't.tgz'); | |
var opts = { | |
hostname: 'registry.npmjs.com', | |
method: 'GET', | |
port: 80, | |
path: '/cutter/-/cutter-0.0.3.tgz', | |
headers: { | |
Connection: 'close' | |
} | |
} | |
http.request(opts, function (res) { | |
console.log('connection: %s', res.headers.connection); | |
res.resume(); | |
res.pause(); | |
setTimeout(function () { | |
var tarball = fs.createWriteStream(tmp, { mode: 420 }) | |
tarball.on('finish', function () { | |
console.log('tarball finish'); | |
}) | |
res.on('data', function (data) { | |
console.log('res on data: %s', data.length); | |
}) | |
res.on('end', function (d) { | |
console.log('res end'); | |
}) | |
res.pipe(tarball); | |
res.resume(); | |
}, 1000); | |
}).end(); | |
// output: | |
// connection: close | |
// res on data: 3144 | |
// res end |
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 http = require('http'); | |
var fs = require('fs'); | |
var path = require('path'); | |
var tmp = path.join(__dirname, 't.tgz'); | |
var opts = { | |
hostname: 'registry.npmjs.com', | |
method: 'GET', | |
port: 80, | |
path: '/cutter/-/cutter-0.0.3.tgz', | |
headers: { | |
Connection: 'close' | |
} | |
} | |
http.request(opts, function (res) { | |
console.log('connection: %s', res.headers.connection); | |
res.resume(); | |
res.pause(); | |
var tarball = fs.createWriteStream(tmp, { mode: 420 }) | |
tarball.on('finish', function () { | |
console.log('tarball finish'); | |
}) | |
res.on('data', function (data) { | |
console.log('res on data: %s', data.length); | |
}) | |
res.on('end', function (d) { | |
console.log('res end'); | |
}) | |
res.pipe(tarball); | |
res.resume(); | |
}).end(); | |
// output: | |
// connection: close | |
// res on data: 3144 | |
// res end | |
// tarball finish | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment