|
|
@@ -56,9 +56,14 @@ function getFileStream(srcUrl, options, cb) {
|
|
|
req.abort();
|
|
|
return cb(new Error('Bad server response code: '+statusCode));
|
|
|
}
|
|
|
- req.setEncoding = res.setEncoding.bind(res); // hack to fix setencoding called from carrier
|
|
|
|
|
|
- var stream = req;
|
|
|
+ res.abort = req.abort.bind(req);
|
|
|
+ // forward all errors to result
|
|
|
+ req.on('error', function(err) {
|
|
|
+ res.emit('error', err);
|
|
|
+ });
|
|
|
+
|
|
|
+ var stream = res;
|
|
|
if (res.headers['content-encoding'] === 'gzip' || res.headers['content-encoding'] === 'deflate') {
|
|
|
unzip = zlib.createUnzip();
|
|
|
stream = res.pipe(unzip);
|