@@ -11,9 +11,7 @@ use governor::{
1111} ;
1212use http:: { header:: HeaderValue , Uri } ;
1313use hyper:: {
14- client:: { HttpConnector , ResponseFuture } ,
15- header:: USER_AGENT ,
16- Body , Client , HeaderMap , Request , Response , StatusCode ,
14+ body:: HttpBody , client:: { HttpConnector , ResponseFuture } , header:: USER_AGENT , Body , Client , HeaderMap , Request , Response , StatusCode
1715} ;
1816use hyper_proxy:: { Intercept , Proxy , ProxyConnector } ;
1917use hyper_rustls:: { HttpsConnector , HttpsConnectorBuilder } ;
@@ -178,9 +176,7 @@ impl HttpClient {
178176 // As correct as that may be technically, we now need all this boilerplate to clone it
179177 // ourselves, as any `Request` is moved in the loop.
180178 let ( parts, body) = req. into_parts ( ) ;
181- let body_as_bytes = hyper:: body:: to_bytes ( body)
182- . await
183- . unwrap_or_else ( |_| Bytes :: new ( ) ) ;
179+ let body_as_bytes = body. collect ( ) . await . map ( |b| b. to_bytes ( ) ) . unwrap_or_default ( ) ;
184180
185181 loop {
186182 let mut req = Request :: builder ( )
@@ -218,7 +214,7 @@ impl HttpClient {
218214
219215 pub async fn request_body ( & self , req : Request < Body > ) -> Result < Bytes , Error > {
220216 let response = self . request ( req) . await ?;
221- Ok ( hyper :: body :: to_bytes ( response. into_body ( ) ) . await ?)
217+ Ok ( response. into_body ( ) . collect ( ) . await ?. to_bytes ( ) )
222218 }
223219
224220 pub fn request_stream ( & self , req : Request < Body > ) -> Result < IntoStream < ResponseFuture > , Error > {
0 commit comments