(timeout: u64, proxy: &str)
| 1842 | } |
| 1843 | |
| 1844 | pub fn create_http_client(timeout: u64, proxy: &str) -> Result<Client, Error> { |
| 1845 | // Ensure the ring provider is installed. Returns Err if already set, which |
| 1846 | // is fine — we just need it present before ClientBuilder::build() runs. |
| 1847 | let _ = rustls::crypto::ring::default_provider().install_default(); |
| 1848 | let mut client_builder = Client::builder() |
| 1849 | .danger_accept_invalid_certs(true) |
| 1850 | .timeout(Duration::from_secs(timeout)); |
| 1851 | if !proxy.is_empty() { |
| 1852 | client_builder = client_builder.proxy(Proxy::all(proxy)?); |
| 1853 | } |
| 1854 | Ok(client_builder.build().unwrap_or_default()) |
| 1855 | } |
| 1856 | |
| 1857 | #[cfg(test)] |
| 1858 | mod tests { |
no test coverage detected