(timeout: u64, proxy: &str, insecure: bool)
| 1876 | } |
| 1877 | |
| 1878 | pub fn create_http_client(timeout: u64, proxy: &str, insecure: bool) -> Result<Client, Error> { |
| 1879 | // Ensure the ring provider is installed. Returns Err if already set, which |
| 1880 | // is fine — we just need it present before ClientBuilder::build() runs. |
| 1881 | let _ = rustls::crypto::ring::default_provider().install_default(); |
| 1882 | let mut client_builder = Client::builder().timeout(Duration::from_secs(timeout)); |
| 1883 | if !proxy.is_empty() { |
| 1884 | client_builder = client_builder.proxy(Proxy::all(proxy)?); |
| 1885 | } |
| 1886 | if insecure { |
| 1887 | client_builder = client_builder.danger_accept_invalid_certs(true); |
| 1888 | } |
| 1889 | Ok(client_builder.build()?) |
| 1890 | } |
| 1891 | |
| 1892 | pub fn format_error(err: &Error) -> String { |
| 1893 | if is_tls_certificate_error(err) { |
no test coverage detected