File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -416,6 +416,10 @@ function asStream(opts) {
416416
417417 const statusCode = res . statusCode ;
418418
419+ res . on ( 'error' , err => {
420+ proxy . emit ( 'error' , new got . ReadError ( err , opts ) ) ;
421+ } ) ;
422+
419423 res . pipe ( output ) ;
420424
421425 if ( statusCode !== 304 && ( statusCode < 200 || statusCode > 299 ) ) {
Original file line number Diff line number Diff line change @@ -66,6 +66,13 @@ test('handles gzip error', async t => {
6666 t . is ( err . name , 'ReadError' ) ;
6767} ) ;
6868
69+ test ( 'handles gzip error - stream' , async t => {
70+ const err = await t . throws ( getStream ( got . stream ( `${ s . url } /corrupted` ) ) ) ;
71+ t . is ( err . message , 'incorrect header check' ) ;
72+ t . is ( err . path , '/corrupted' ) ;
73+ t . is ( err . name , 'ReadError' ) ;
74+ } ) ;
75+
6976test ( 'decompress option opts out of decompressing' , async t => {
7077 const response = await got ( s . url , { decompress : false } ) ;
7178 t . true ( Buffer . compare ( response . body , gzipData ) === 0 ) ;
You can’t perform that action at this time.
0 commit comments