Summary
crates/iroh-http-core/src/server.rs#L863-906 implements the compression-skip predicates as hand-written closures. tower_http::compression::predicate::DefaultPredicate already covers the standard set and chains via .and(). Use it instead, then add only the project-specific predicates on top.
Follow-up to the post-rework review at reviews/2026-04-30-post-rework-review.md §5.4.
Evidence
tower_http::compression::predicate provides DefaultPredicate (size + content-type + already-encoded) and NotForContentType, SizeAbove building blocks.
- Our predicate logic (server.rs#L863-906) duplicates the "already encoded" and "no-transform" checks.
Impact
- Drift risk if upstream improves the default predicate (e.g. adds a media-type).
- More code to read and test for the same effect.
Remediation
- Replace the manual closure stack with
DefaultPredicate::default().and(NotForContentType::new("application/zstd")).and(NoTransformCacheControl) (where NoTransformCacheControl is a small custom predicate if not in tower-http).
- Verify the threshold passes through (
SizeAbove(min_body_bytes) is part of DefaultPredicate configurable via .with_size_above).
- Remove the bespoke closures.
Acceptance criteria
- Predicate composition uses
DefaultPredicate + named building blocks.
- All compression behaviour preserved (covered by existing tests).
- ~30 lines removed from
server.rs.
Summary
crates/iroh-http-core/src/server.rs#L863-906implements the compression-skip predicates as hand-written closures.tower_http::compression::predicate::DefaultPredicatealready covers the standard set and chains via.and(). Use it instead, then add only the project-specific predicates on top.Follow-up to the post-rework review at reviews/2026-04-30-post-rework-review.md §5.4.
Evidence
tower_http::compression::predicateprovidesDefaultPredicate(size + content-type + already-encoded) andNotForContentType,SizeAbovebuilding blocks.Impact
Remediation
DefaultPredicate::default().and(NotForContentType::new("application/zstd")).and(NoTransformCacheControl)(whereNoTransformCacheControlis a small custom predicate if not in tower-http).SizeAbove(min_body_bytes)is part ofDefaultPredicateconfigurable via.with_size_above).Acceptance criteria
DefaultPredicate+ named building blocks.server.rs.