tonhowtf/omniget · error

download de falhou: HTTP

Error message

download de {} falhou: HTTP {}

What it means

HTTP status guard in download_to: the streaming download request for `url` completed but the server answered a non-2xx status, so no body is written to `dest` and the bail carries the failing URL and status code.

Solutions

  1. Verify the URL resolves (curl -I) and fix or refresh it
  2. Retry with exponential backoff, especially for 429/5xx
  3. Add auth headers/cookies or a browser-like User-Agent if the server returns 403
  4. Handle 404 by skipping or sourcing the file elsewhere

Example fix

// before
download_to(&client, old_url, &dest).await?; // 404
// after
let fresh_url = refresh_url(id).await?;
download_to(&client, &fresh_url, &dest).await?;
Defensive patterns

Strategy: retry

Validate before calling

// optional pre-check of URL liveness
let resp = client.head(url).send().await?;
if !resp.status().is_success() {
    return Err(format!("URL not downloadable: HTTP {}", resp.status()));
}

Try / catch

match download_to(&client, url, &dest).await {
    Ok(n) => info!("saved {} bytes", n),
    Err(e) if e.to_string().contains("falhou: HTTP 4") => warn!("permanent failure, skip: {}", e),
    Err(e) if e.to_string().contains("falhou: HTTP 5") => {
        retry_with_backoff(3, || download_to(&client, url, &dest)).await?;
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Any `download_to(client, url, dest)` call where `resp.status().is_success()` is false: 404 (URL gone), 403 (forbidden/hotlink protection), 429 (rate limit), 5xx (server error).

Common situations: Downloading an asset whose URL rotated or expired; server blocking non-browser user agents; mirror/CDN outage; scraping too fast and hitting throttling.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/c107493e2a037230. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/mod.rs:169

            .timeout(std::time::Duration::from_secs(600))
            .build()?,
    )
}

/// Baixa uma URL para um arquivo, em streaming, reportando bytes.
pub async fn download_to(
    client: &reqwest::Client,
    url: &str,
    dest: &std::path::Path,
    progress: &ProgressFn,
    id: &str,
) -> anyhow::Result<u64> {
    use futures::StreamExt;
    use tokio::io::AsyncWriteExt;

    let resp = client.get(url).send().await?;
    if !resp.status().is_success() {
        anyhow::bail!("download de {} falhou: HTTP {}", url, resp.status());
    }
    let total = resp.content_length();
    if let Some(parent) = dest.parent() {
        std::fs::create_dir_all(parent)?;
    }
    let part = dest.with_extension("part");
    let mut file = tokio::fs::File::create(&part).await?;
    let mut stream = resp.bytes_stream();
    let mut done: u64 = 0;
    let mut last = std::time::Instant::now();
    report(progress, id, "started", 0, total, None);
    while let Some(chunk) = stream.next().await {
        let chunk = chunk?;
        file.write_all(&chunk).await?;
        done += chunk.len() as u64;
        if last.elapsed() > std::time::Duration::from_millis(200) {
            report(progress, id, "progress", done, total, None);
            last = std::time::Instant::now();

View on GitHub (pinned to 8600b91f42)