From f4ecfb2dff83d5d067e18482aeb27d7bd478c123 Mon Sep 17 00:00:00 2001 From: Atirna <288419661+atirna@users.noreply.github.com> Date: Wed, 2 Sep 2026 07:56:15 +0530 Subject: [PATCH] fix(http3): update cached Alt-Svc support --- impit/src/http3.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/impit/src/http3.rs b/impit/src/http3.rs index 0cefa059..7391460c 100644 --- a/impit/src/http3.rs +++ b/impit/src/http3.rs @@ -78,10 +78,25 @@ impl H3Engine { 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); } } + +#[cfg(test)] +mod tests { + use super::*; + + #[tokio::test] + async fn alt_svc_discovery_updates_cached_h3_support() { + let engine = H3Engine::init().await; + let host = "example.com".to_string(); + let other_host = "other.example.com".to_string(); + + engine.set_h3_support(&host, false).await; + engine.set_h3_support(&other_host, false).await; + engine.set_h3_support(&host, true).await; + + assert!(engine.host_supports_h3(&host).await); + assert!(!engine.host_supports_h3(&other_host).await); + } +}