@@ -275,7 +275,12 @@ impl HttpClient {
275
275
std:: io:: ErrorKind :: InvalidInput , "unsupported transfer coding" ) )
276
276
} else {
277
277
#[ cfg( feature = "tokio" ) ]
278
- let reader = ReadAdapter ( & mut reader) ;
278
+ let reader = {
279
+ // Read the stream into a buffer since chunked_transfer isn't async.
280
+ let mut buffer = Vec :: new ( ) ;
281
+ reader. read_to_end ( & mut buffer) . await ?;
282
+ std:: io:: Cursor :: new ( buffer)
283
+ } ;
279
284
let mut decoder = chunked_transfer:: Decoder :: new ( reader) ;
280
285
let mut content = Vec :: new ( ) ;
281
286
decoder. read_to_end ( & mut content) ?;
@@ -362,18 +367,6 @@ enum HttpMessageLength {
362
367
TransferEncoding ( String ) ,
363
368
}
364
369
365
- /// An adaptor for making `tokio::io::AsyncRead` compatible with interfaces expecting
366
- /// `std::io::Read`. This effectively makes the adapted object synchronous.
367
- #[ cfg( feature = "tokio" ) ]
368
- struct ReadAdapter < ' a , R : tokio:: io:: AsyncRead + std:: marker:: Unpin > ( & ' a mut R ) ;
369
-
370
- #[ cfg( feature = "tokio" ) ]
371
- impl < ' a , R : tokio:: io:: AsyncRead + std:: marker:: Unpin > std:: io:: Read for ReadAdapter < ' a , R > {
372
- fn read ( & mut self , buf : & mut [ u8 ] ) -> std:: io:: Result < usize > {
373
- futures:: executor:: block_on ( self . 0 . read ( buf) )
374
- }
375
- }
376
-
377
370
/// An HTTP response body in binary format.
378
371
pub ( crate ) struct BinaryResponse ( pub ( crate ) Vec < u8 > ) ;
379
372
0 commit comments