Closed piranna closed 8 years ago
Bump, I would like to use .use
to check headers before continuing the download process but throwing an error doesn't cleanly exit.
Plugins are now removed. I'm returning the full stream so that you can do whatever you want with it.
Have you removed the .use()
function? How are they used now, with .pipe()
?
download
returns a stream (and a promise), so you can just listen on the response event.
const dl = download('cat.com/dancing.gif');
dl.on('response', res => {
res.on('data', yourFunction);
};
dl.then(() => console.log('done!'));
:+1:
The call to
ware
at https://github.com/kevva/download/blob/bac7dd9913302c37564b087f9e198658f5692234/index.js#L125-L129 doesn't a callback, so any error produced when registering the plugins are ignored. The same happen with the errors generated by them, since the stream is downloaded and decompressed in a different path two lines below. I think the call toreadAllStream()
should be done inside that callback I say inside the 'response' event. Maybe there would be problems due to issue #83, but I think both can be fixed at the same time.