seanmonstar/reqwest · error · reqwest::Error

error sending request

Error message

error sending request

What it means

Returned by `extract_domain` (pool.rs:383) in the fallthrough arm where the URI has no scheme and/or no authority (host). It is a `Kind::Request` error with no inner source, meaning the request URI was structurally incomplete for forming an HTTP/3 connection key.

Source

Thrown at src/async_impl/h3_client/pool.rs:383

    let uri_clone = uri.clone();
    match (uri_clone.scheme(), uri_clone.authority()) {
        (Some(scheme), Some(auth)) => {
            let scheme_str = scheme.as_str();
            if scheme_str != "https" && scheme_str != "h3" {
                return Err(Error::new(
                    Kind::Request,
                    Some(Box::new(std::io::Error::new(
                        std::io::ErrorKind::InvalidInput,
                        format!(
                            "HTTP/3 only supports 'https' or 'h3' schemes, got: {}",
                            scheme_str
                        ),
                    ))),
                ));
            }
            Ok((scheme.clone(), auth.clone()))
        }
        _ => Err(Error::new(Kind::Request, None::<Error>)),
    }
}

pub(crate) fn domain_as_uri((scheme, auth): Key) -> Uri {
    http::uri::Builder::new()
        .scheme(scheme)
        .authority(auth)
        .path_and_query("/")
        .build()
        .expect("domain is valid Uri")
}

/// Indicates the remote requested the peer to stop sending data without error.
fn is_stop_sending(e: &h3::error::StreamError) -> bool {
    matches!(
        e,
        h3::error::StreamError::RemoteTerminate {
            code: h3::error::Code::H3_NO_ERROR,

View on GitHub (pinned to 17e9bcb51c)

Solutions

  1. Ensure the request URI is absolute with scheme and authority, e.g. `https://host/path`, before sending through the HTTP/3 client.
  2. Let reqwest parse the URL via `IntoUrl` rather than constructing the `Uri` by hand.
  3. Check `req.uri().authority().is_some()` and `.scheme().is_some()` before dispatch.

Example fix

// before
let req = Request::builder()
    .uri("/api/v1/users")          // no scheme/host
    .body(Body::empty())?;

// after
let req = Request::builder()
    .uri("https://api.example.com/api/v1/users")
    .body(Body::empty())?;
Defensive patterns

Strategy: validation

Validate before calling

fn uri_has_origin(u: &http::Uri) -> bool {
    u.scheme().is_some() && u.authority().is_some()
}
assert!(uri_has_origin(req.uri()), "URI must be absolute with scheme+authority");

Type guard

fn is_originless_uri(e: &reqwest::Error) -> bool {
    e.is_request() && e.source().is_none()
}

Try / catch

let r = h3_client.request(req).await.map_err(|e| {
    if is_originless_uri(&e) { anyhow!("request URI needs scheme+host") } else { e.into() }
})?;

Prevention

When it happens

Trigger: Dispatching a request through the HTTP/3 client with a relative URI (`/path`), a URI with no host (`http:///path`), or a manually built `http::Request` whose `Uri` lacks scheme/authority.

Common situations: Building a request with `Request::builder().uri("/users")` and sending through h3; URL rewrite stripping the host; proxy/forwarder constructing URIs without the origin.

Related errors


AI-assisted analysis of seanmonstar/reqwest@17e9bcb51c (2026-08-06). Data as JSON: /data/errors/568bf886ce9fa855.json. Report an issue: GitHub.