tonhowtf/omniget · error · anyhow::Error
Failed to build HTTP client
Error message
Failed to build HTTP client: {} What it means
The reqwest `ClientBuilder::build()` call failed while constructing the HTTP client used for the direct file download (headers, cookies, redirects already configured). This is a client-construction failure, not a request failure — typically invalid TLS backend state or bad builder configuration.
Solutions
- Read the wrapped error message in `Failed to build HTTP client: {}` to identify the root cause (usually TLS).
- Enable a TLS feature on reqwest in Cargo.toml, e.g. `reqwest = { version = "...", features = ["rustls-tls"] }`.
- If using a custom cookie jar, verify it is constructed correctly and not poisoned before passing to `cookie_provider`.
- Check the deployment image includes the CA/OpenSSL runtime files needed by the chosen TLS backend.
Example fix
// before (Cargo.toml)
reqwest = "0.12"
// after (Cargo.toml)
reqwest = { version = "0.12", features = ["rustls-tls", "cookies"] } Defensive patterns
Strategy: try-catch
Validate before calling
// Rust, sanity-check TLS backend support at startup
let probe = reqwest::Client::builder().timeout(std::time::Duration::from_secs(10)).build();
if probe.is_err() {
eprintln!("reqwest client cannot be built — check TLS features/features in Cargo.toml");
} Try / catch
// Rust
match build_client(jar).await {
Ok(client) => client,
Err(e) => {
log::error!("HTTP client build failed: {e:#}; verify reqwest TLS/cookies features");
return Err(anyhow!("HTTP client unavailable: {e}"));
}
} Prevention
- Always enable a TLS feature (rustls-tls or native-tls) for reqwest in Cargo.toml.
- Probe client construction in a startup health check rather than at download time.
- Keep cookie jar construction simple and tested; avoid reusing possibly-poisoned shared jars.
When it happens
Trigger: Calling `download` when the reqwest builder cannot be finalized — e.g. TLS backend initialization failure (rustls/native-tls issues), a bad `cookie_provider` jar, or conflicting builder options.
Common situations: Missing/incorrectly linked TLS backend (no `default-tls`/`rustls-tls` feature enabled in a static build), a custom cookie jar whose Arc/RwLock is poisoned, or platform-specific crypto issues on stripped-down Docker images.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Failed to download attachment
- probe failed
- Failed to build HTTP client
- YouTube não retornou URL
- HTTP fetching playlist
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/f6c1a58b5f12fdaa.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/src/platforms/direct_file/mod.rs:132
let mut builder = http_client::apply_global_proxy(reqwest::Client::builder())
.connect_timeout(std::time::Duration::from_secs(30));
if let Some(ua) = opts.user_agent.as_deref() {
builder = builder.user_agent(ua);
}
let jar = crate::core::cookie_parser::load_extension_cookies_for_url(file_url).or_else(|| {
opts.referer
.as_deref()
.and_then(crate::core::cookie_parser::load_extension_cookies_for_url)
});
if let Some(jar) = jar {
builder = builder.cookie_provider(jar);
}
let client = builder
.build()
.map_err(|e| anyhow!("Failed to build HTTP client: {}", e))?;
let mut headers = reqwest::header::HeaderMap::new();
if let Some(ref r) = opts.referer {
if let Ok(val) = reqwest::header::HeaderValue::from_str(r) {
headers.insert(reqwest::header::REFERER, val);
}
}
if let Some(ref hdrs) = opts.extra_headers {
for (name, value) in hdrs {
if let (Ok(hname), Ok(hval)) = (
reqwest::header::HeaderName::from_bytes(name.as_bytes()),
reqwest::header::HeaderValue::from_str(value),
) {
headers.insert(hname, hval);
}
}
}
http_client::inject_ua_header(&mut headers, opts.user_agent.as_deref());View on GitHub (pinned to 8600b91f42)