0.34.6_repo_cleanup

This commit is contained in:
Mateusz Gruszczyński committed 2026-10-22 09:31:15 +02:00
1 parent ce1a90397c
commit 133d2f0f91
273 files changed
+5969 -6926

No files matched your search

-19
View File
@@ -1,6 +1,3 @@
/// Transform an eligible response. The call is fail-open for unsupported media,
/// encodings and malformed minifiable content; transport/body collection errors
/// still propagate because the original stream can no longer be replayed safely.
pub async fn apply(
response: Response,
path: &str,
@@ -46,8 +43,6 @@ pub async fn apply(
.and_then(|value| value.to_str().ok())
.and_then(|value| value.parse::<usize>().ok())
else {
// Keep streaming semantics for unknown-size bodies instead of introducing
// unbounded buffering into the dataplane.
return Ok(skip(response, Some(kind), "unknown_length"));
};
if content_length > settings.max_body_bytes {
@@ -64,18 +59,10 @@ pub async fn apply(
let Some(_memory_reservation) =
try_reserve_transform_memory(required_memory, settings.memory_budget_bytes)
else {
// Transformations are an optimization. Under concurrent allocation
// pressure, preserve streaming/origin bytes instead of queueing more
// full-response buffers behind the memory budget.
return Ok(skip(response, Some(kind), "memory_pressure"));
};
let (mut parts, body) = response.into_parts();
// Do not trust Content-Length as a memory bound. A broken or malicious
// upstream can send more bytes than declared; Limited stops aggregation at
// the configured ceiling instead of letting BodyExt::collect grow without
// bound. Once aggregation starts an over-limit stream cannot be replayed
// safely, so it is treated like the other body/transport collection errors.
let raw = Limited::new(body, settings.max_body_bytes)
.collect()
.await
@@ -114,9 +101,6 @@ pub async fn apply(
}
};
if transformed.as_slice() == decoded.as_ref() && encoding.is_none() {
// The origin was explicitly requested without Accept-Encoding and the
// eligible response is already identity. The bytes/validator stay intact,
// but the cache no longer needs an Accept-Encoding variant dimension.
drop_vary_accept_encoding(&mut parts.headers);
parts.extensions.insert(CanonicalIdentity);
parts.extensions.insert(Skipped {
@@ -128,9 +112,6 @@ pub async fn apply(
let original_bytes = decoded.len();
let released_bytes = raw.len().saturating_add(decoded.len());
// The successful transformed response no longer needs the collected origin
// body or decoded temporary buffer. Drop both before building the response so
// large short-lived allocations do not overlap longer than necessary.
drop(decoded);
drop(raw);
trim_allocator_after_large_transform(released_bytes);