File tree Expand file tree Collapse file tree 3 files changed +13
-10
lines changed
Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -29,8 +29,7 @@ cached = "0.30"
2929tracing-subscriber = { version = " 0.3" , features = [" fmt" , " local-time" ] }
3030time = { version = " 0.3" , features = [" macros" , " local-offset" ] }
3131dashmap = " 5.2"
32- hyper = { version = " 0.14" , features = [" client" , " http1" ] }
33- hyper-tls = { version = " 0.5" , features = [" vendored" ] }
32+ reqwest = { version = " 0.11" , features = [" native-tls-vendored" ] }
3433chrono = " 0.4"
3534xml-rs = " 0.8"
3635async-recursion = " 1.0.0"
Original file line number Diff line number Diff line change @@ -27,8 +27,8 @@ pub enum RCError {
2727 PB ( #[ from] prost:: DecodeError ) ,
2828 #[ error( "rq error, {0}" ) ]
2929 RQ ( #[ from] RQError ) ,
30- #[ error( "hyper error, {0}" ) ]
31- Hyper ( #[ from] hyper :: Error ) ,
30+ #[ error( "reqwest error, {0}" ) ]
31+ Reqwest ( #[ from] reqwest :: Error ) ,
3232 #[ error( "base64 decode error, {0}" ) ]
3333 Base64Decode ( #[ from] base64:: DecodeError ) ,
3434 #[ error( "invalid uri error, {0}" ) ]
Original file line number Diff line number Diff line change 1- use hyper:: { Body , Client , Request } ;
1+ use std:: time:: Duration ;
2+
23use tokio:: io:: AsyncReadExt ;
34
45use crate :: error:: { RCError , RCResult } ;
@@ -17,13 +18,16 @@ pub async fn get_binary(uri: &str) -> RCResult<Vec<u8>> {
1718}
1819
1920pub async fn http_get ( uri : & str ) -> RCResult < Vec < u8 > > {
20- let cli = Client :: builder ( ) . build :: < _ , Body > ( hyper_tls:: HttpsConnector :: new ( ) ) ;
21- let req = Request :: builder ( ) . uri ( uri) . body ( Body :: empty ( ) ) ?;
22- let resp = cli. request ( req) . await ?;
23- hyper:: body:: to_bytes ( resp. into_body ( ) )
21+ reqwest:: Client :: builder ( )
22+ . timeout ( Duration :: from_secs ( 60 ) )
23+ . build ( ) ?
24+ . get ( uri)
25+ . send ( )
26+ . await ?
27+ . bytes ( )
2428 . await
2529 . map ( |b| b. to_vec ( ) )
26- . map_err ( crate :: error :: RCError :: Hyper )
30+ . map_err ( RCError :: from )
2731}
2832
2933pub async fn read_binary_file ( path : & str ) -> RCResult < Vec < u8 > > {
You can’t perform that action at this time.
0 commit comments