File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -589,11 +589,20 @@ fn poll_response(
589589 if encoding == "gzip" {
590590 let mut gz = GzDecoder :: new ( & result[ ..] ) ;
591591 let mut s = String :: new ( ) ;
592- gz. read_to_string ( & mut s) . unwrap ( ) ;
592+ if let Err ( err) = gz. read_to_string ( & mut s) {
593+ log:: error!( "Error decoding gzip: {}" , err) ;
594+ }
595+ s. as_bytes ( ) . to_vec ( )
596+ } else if encoding == "deflate" {
597+ let mut gz = flate2:: read:: ZlibDecoder :: new ( & result[ ..] ) ;
598+ let mut s = String :: new ( ) ;
599+ if let Err ( err) = gz. read_to_string ( & mut s) {
600+ log:: error!( "Error decoding deflate: {}" , err) ;
601+ }
593602 s. as_bytes ( ) . to_vec ( )
594603 } else {
595- // FIXME: handle other encodings and throw exception instead of panic
596- panic ! ( "unknown encoding: {}" , encoding . to_str ( ) . unwrap ( ) ) ;
604+ log :: error! ( "Unknown encoding: {}" , encoding . to_str ( ) . unwrap ( ) ) ;
605+ result . clone ( )
597606 }
598607 } else {
599608 result. clone ( )
You can’t perform that action at this time.
0 commit comments