(timeout: u64, proxy: &str)
| 1824 | } |
| 1825 | |
| 1826 | pub fn create_http_client(timeout: u64, proxy: &str) -> Result<Client, Error> { |
| 1827 | // Ensure the ring provider is installed. Returns Err if already set, which |
| 1828 | // is fine — we just need it present before ClientBuilder::build() runs. |
| 1829 | let _ = rustls::crypto::ring::default_provider().install_default(); |
| 1830 | let mut client_builder = Client::builder() |
| 1831 | .danger_accept_invalid_certs(true) |
| 1832 | .timeout(Duration::from_secs(timeout)); |
| 1833 | if !proxy.is_empty() { |
| 1834 | client_builder = client_builder.proxy(Proxy::all(proxy)?); |
| 1835 | } |
| 1836 | Ok(client_builder.build().unwrap_or_default()) |
| 1837 | } |
| 1838 | |
| 1839 | #[cfg(test)] |
| 1840 | mod tests { |
no test coverage detected