When attempting to download a (largish) file via https.request and using agent: false, the end of the file will frequently be missing.
https://gist.github.com/trentm/80409ded30b4e0418e9c has a demo script and sample runs showing it failing on node 0.10.40 and node 4.1.1. In my experience I get a failure between 10% - 80% of the time.
There is a sample run with agent: false commented out which shows successful downloads a dozen or more times in a row.
My sample script just does manual writing of 'data' chunks from the res (response) to a file (fs.createWriteStream): https://gist.github.com/trentm/80409ded30b4e0418e9c#file-download-sans-agent-js-L83-L86
This was me trying to eliminate .pipe() usage as a possible cause.
https://gist.github.com/trentm/5d3c4d9dbcb7c3b8dbaa is an equivalent script (and sample runs) using res.pipe(outStream). It fails frequently as well.
When attempting to download a (largish) file via
https.requestand usingagent: false, the end of the file will frequently be missing.https://gist.github.com/trentm/80409ded30b4e0418e9c has a demo script and sample runs showing it failing on node 0.10.40 and node 4.1.1. In my experience I get a failure between 10% - 80% of the time.
There is a sample run with
agent: falsecommented out which shows successful downloads a dozen or more times in a row.My sample script just does manual writing of 'data' chunks from the
res(response) to a file (fs.createWriteStream): https://gist.github.com/trentm/80409ded30b4e0418e9c#file-download-sans-agent-js-L83-L86This was me trying to eliminate
.pipe()usage as a possible cause.https://gist.github.com/trentm/5d3c4d9dbcb7c3b8dbaa is an equivalent script (and sample runs) using
res.pipe(outStream). It fails frequently as well.