feat: update fetch-rs
This commit is contained in:
@@ -6,5 +6,5 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
reqwest = { version = "0.11.18", features = ["blocking", "rustls-tls"] }
|
||||
reqwest = { version = "0.11.18", features = ["blocking", "rustls-tls", "native-tls"] }
|
||||
rust_util = "0.6.41"
|
||||
|
||||
@@ -119,7 +119,7 @@ pub struct FetchOptions {
|
||||
pub method: FetchMethod,
|
||||
pub headers: Vec<FetchHeader>,
|
||||
pub body: Option<Vec<u8>>,
|
||||
// FIXME connect timeout or read timeout?
|
||||
pub connect_timeout: Option<Duration>,
|
||||
pub timeout: Option<Duration>,
|
||||
pub proxy: Option<String>,
|
||||
// TODO hsts supports
|
||||
@@ -172,6 +172,12 @@ pub fn fetch(url: &str, option: &FetchOptions) -> XResult<FetchResponse> {
|
||||
}
|
||||
}
|
||||
}
|
||||
let connect_timeout = match &option.connect_timeout {
|
||||
Some(connect_timeout) => connect_timeout.to_owned(),
|
||||
None => Duration::from_secs(5),
|
||||
};
|
||||
client_builder = client_builder.connect_timeout(connect_timeout);
|
||||
// client_builder = client_builder.timeout(Duration::from_secs(50));
|
||||
let client = client_builder.build()?;
|
||||
let method = match option.method {
|
||||
FetchMethod::Get => Method::GET,
|
||||
|
||||
Reference in New Issue
Block a user