Skip to content

Alt-Svc HTTP/3 discovery is dead: set_h3_support early-returns before the Alt-Svc upgrade #471

Description

@barjin

🤖 Found by Claude ultrareview — automated high-effort code review. Please verify independently before acting.

Location: impit/src/http3.rs:79 (set_h3_support), triggered from impit/src/impit.rs:535-547

set_h3_support() early-returns when the host key already exists:

pub async fn set_h3_support(&self, host: &String, supports_h3: bool) {
    let mut cache = self.h3_alt_svc.write().await;
    if cache.contains_key(host) {
        return;
    }
    cache.insert(host.to_owned(), supports_h3);
}

In send(), after a non-h3 response the code first calls set_h3_support(&host, false) unconditionally, then, if the response carries Alt-Svc: h3, calls set_h3_support(&host, true):

if !h3 {
    if let Some(h3_engine) = engine_guard.as_ref() {
        h3_engine.set_h3_support(&host, false).await;          // inserts host -> false
        if let Some(alt_svc) = response.headers().get("Alt-Svc") {
            if /* contains h3 */ {
                h3_engine.set_h3_support(&host, true).await;    // dropped: key already exists
            }
        }
    }
}

Because the first false insert wins, the later true update is silently dropped.

Impact: A server that advertises HTTP/3 only via the Alt-Svc response header (not via DNS HTTPS records) is never cached as h3-capable, so HTTP/3 is never used for it on subsequent requests. Alt-Svc-based discovery — one of the two documented discovery mechanisms — is effectively dead code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working.rustThis issue concerns the Rust part of this monorepo.t-toolingIssues with this label are in the ownership of the tooling team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions