This commit is contained in:
Mateusz Gruszczyński committed 2026-10-08 09:42:10 +02:00
1 parent c24bc4279b
commit 3b3f0db377
84 files changed
+2686 -392

No files matched your search

+15
View File
@@ -126,6 +126,15 @@ impl Settings {
(1..=64).contains(&self.proactive_refresh_max_inflight),
"cache.proactive_refresh_max_inflight must be 1..64"
);
if let Some(value) = &self.via_header {
ensure!(
!value.is_empty()
&& value.len() <= 256
&& value.bytes().all(|byte| byte >= 0x20 && byte != 0x7f)
&& value.parse::<HeaderValue>().is_ok(),
"cache.via_header must be a valid 1..256 byte HTTP header value"
);
}
Ok(())
}
pub fn active_for(&self, route: Option<bool>) -> bool {
@@ -173,6 +182,12 @@ impl Settings {
if !self.enabled {
return;
}
if let Some(value) = &self.via_header {
headers.append(
http::header::VIA,
value.parse::<HeaderValue>().expect("validated cache Via header"),
);
}
if self.expose_status {
headers.insert("x-cache", HeaderValue::from_static(outcome));
}