Merge branch 'timeout'
commit
7ddc785a9a
|
@ -105,6 +105,7 @@ pub struct ClientConfig {
|
||||||
user_agent: Option<HeaderValue>,
|
user_agent: Option<HeaderValue>,
|
||||||
disable_ssl_verification: bool,
|
disable_ssl_verification: bool,
|
||||||
base_config: BaseClientConfig,
|
base_config: BaseClientConfig,
|
||||||
|
timeout: Option<Duration>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[cfg_attr(tarpaulin, skip)]
|
// #[cfg_attr(tarpaulin, skip)]
|
||||||
|
@ -198,6 +199,12 @@ impl ClientConfig {
|
||||||
self.base_config = self.base_config.passphrase(passphrase);
|
self.base_config = self.base_config.passphrase(passphrase);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set a timeout duration for all HTTP requests. The default is no timeout.
|
||||||
|
pub fn timeout(mut self, timeout: Duration) -> Self {
|
||||||
|
self.timeout = Some(timeout);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
|
@ -314,6 +321,11 @@ impl Client {
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let http_client = {
|
let http_client = {
|
||||||
|
let http_client = match config.timeout {
|
||||||
|
Some(x) => http_client.timeout(x),
|
||||||
|
None => http_client,
|
||||||
|
};
|
||||||
|
|
||||||
let http_client = if config.disable_ssl_verification {
|
let http_client = if config.disable_ssl_verification {
|
||||||
http_client.danger_accept_invalid_certs(true)
|
http_client.danger_accept_invalid_certs(true)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue