{"id":"23cfb8016bdd1fc9","repo":"seanmonstar/reqwest","slug":"http-3-only-supports-https-or-h3-schemes-got","errorCode":null,"errorMessage":"HTTP/3 only supports 'https' or 'h3' schemes, got: {}","messagePattern":"HTTP/3 only supports 'https' or 'h3' schemes, got: (.+?)","errorType":"validation","errorClass":"reqwest::Error","httpStatus":null,"severity":"error","filePath":"src/async_impl/h3_client/pool.rs","lineNumber":374,"sourceCode":"        if let Some(content_length) = self.content_length {\n            hyper::body::SizeHint::with_exact(content_length)\n        } else {\n            hyper::body::SizeHint::default()\n        }\n    }\n}\n\npub(crate) fn extract_domain(uri: &mut Uri) -> Result<Key, Error> {\n    let uri_clone = uri.clone();\n    match (uri_clone.scheme(), uri_clone.authority()) {\n        (Some(scheme), Some(auth)) => {\n            let scheme_str = scheme.as_str();\n            if scheme_str != \"https\" && scheme_str != \"h3\" {\n                return Err(Error::new(\n                    Kind::Request,\n                    Some(Box::new(std::io::Error::new(\n                        std::io::ErrorKind::InvalidInput,\n                        format!(\n                            \"HTTP/3 only supports 'https' or 'h3' schemes, got: {}\",\n                            scheme_str\n                        ),\n                    ))),\n                ));\n            }\n            Ok((scheme.clone(), auth.clone()))\n        }\n        _ => Err(Error::new(Kind::Request, None::<Error>)),\n    }\n}\n\npub(crate) fn domain_as_uri((scheme, auth): Key) -> Uri {\n    http::uri::Builder::new()\n        .scheme(scheme)\n        .authority(auth)\n        .path_and_query(\"/\")\n        .build()","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/seanmonstar/reqwest/blob/17e9bcb51c46edebfb6f5f2f5184b51dac4b3a7d/src/async_impl/h3_client/pool.rs#L356-L392","documentation":"Raised by `extract_domain` in the HTTP/3 pool (pool.rs:369-379) when a request URI's scheme is neither `https` nor `h3`. HTTP/3 mandates TLS 1.3 over QUIC, so plaintext schemes are rejected up front before any connection is attempted.","triggerScenarios":"Calling an HTTP/3 client (built with the `http3` feature) against a `http://` URL, a `ws://` URL, or any custom scheme like `ftp://`. Also when a request is manually constructed with `Request::builder().uri(\"http://...\")` and dispatched through the h3 service.","commonSituations":"Developer enables `http3_only()` but still hits `http://` dev URLs (e.g. localhost); configuration loaded scheme dynamically and the http fallback path wasn't wired; mixed redirect chain where a redirect target is `http://`.","solutions":["Use an `https://` (or `h3://`) URL for any request going through the HTTP/3 client.","Do not set `.http3_only()` if you need to reach plaintext `http://` endpoints; drop to `.http3_prior_knowledge()` only on known h3 hosts, or use a plain client for http.","Validate the URL scheme before dispatch when scheme is user-supplied."],"exampleFix":"// before\nlet client = Client::builder().http3_only().build()?;\nlet r = client.get(\"http://api.example.com\").send().await?; // rejected\n\n// after\nlet url = if !url.starts_with(\"https://\") { format!(\"https://{url}\") } else { url };\nlet r = client.get(url).send().await?;","handlingStrategy":"validation","validationCode":"fn h3_url_ok(u: &str) -> bool {\n    u.starts_with(\"https://\") || u.starts_with(\"h3://\")\n}\n// guard\nif !h3_url_ok(&url) { return Err(anyhow!(\"h3 requires https:// or h3://\")); }\n","typeGuard":"fn is_h3_bad_scheme(e: &reqwest::Error) -> bool {\n    e.is_request()\n        && e.source().map(|s| s.to_string().contains(\"HTTP/3 only supports\")).unwrap_or(false)\n}\n","tryCatchPattern":"let resp = client.get(&url).send().await.map_err(|e| {\n    if is_h3_bad_scheme(&e) { anyhow::anyhow!(\"use https:// for h3 client\") } else { e.into() }\n})?;","preventionTips":["Normalize all outbound URLs to https:// before sending.","Avoid .http3_only() unless every target is known to be https+h3."],"tags":["http3","url","scheme","validation"],"analyzedSha":"17e9bcb51c46edebfb6f5f2f5184b51dac4b3a7d","analyzedAt":"2026-08-06T01:23:05.134Z","schemaVersion":2}