diff options
Diffstat (limited to 'src/util.rs')
-rw-r--r-- | src/util.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/util.rs b/src/util.rs index feafa467..6dd6c4a7 100644 --- a/src/util.rs +++ b/src/util.rs @@ -478,7 +478,6 @@ pub fn retry<F, T, E>(func: F, max_tries: u32) -> Result<T, E> where F: Fn() -> Result<T, E>, { - use std::{thread::sleep, time::Duration}; let mut tries = 0; loop { @@ -497,12 +496,13 @@ where } } +use std::{thread::sleep, time::Duration}; + pub fn retry_db<F, T, E>(func: F, max_tries: u32) -> Result<T, E> where F: Fn() -> Result<T, E>, E: std::error::Error, { - use std::{thread::sleep, time::Duration}; let mut tries = 0; loop { @@ -522,3 +522,18 @@ where } } } + +use reqwest::{blocking::{Client, ClientBuilder}, header}; + +pub fn get_reqwest_client() -> Client { + get_reqwest_client_builder().build().expect("Failed to build client") +} + +pub fn get_reqwest_client_builder() -> ClientBuilder { + let mut headers = header::HeaderMap::new(); + headers.insert(header::USER_AGENT, header::HeaderValue::from_static("Bitwarden_RS")); + Client::builder() + .default_headers(headers) + .timeout(Duration::from_secs(10)) + +} |