Skip to content

Avoid allocation when detecting content encoding#753

Open
ChristianPavilonis wants to merge 1 commit into
mainfrom
issue-434-compression-encoding
Open

Avoid allocation when detecting content encoding#753
ChristianPavilonis wants to merge 1 commit into
mainfrom
issue-434-compression-encoding

Conversation

@ChristianPavilonis

Copy link
Copy Markdown
Collaborator

Summary

  • Avoid allocating a lowercase String when detecting response compression from Content-Encoding.
  • Preserve existing ASCII case-insensitive matching for gzip, deflate, and br.

Changes

File Change
crates/trusted-server-core/src/streaming_processor.rs Replaced to_lowercase() matching in Compression::from_content_encoding with non-allocating eq_ignore_ascii_case checks.

Closes

Closes #434

Test plan

  • cargo test --workspace
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check
  • JS tests: cd crates/js/lib && npx vitest run
  • JS format: cd crates/js/lib && npm run format
  • Docs format: cd docs && npm run format
  • WASM build: cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1
  • Manual testing via fastly compute serve
  • Other: cargo test -p trusted-server-core streaming_processor::tests::test_compression_detection; cargo test -p trusted-server-core

Checklist

  • Changes follow CLAUDE.md conventions
  • No unwrap() in production code — use expect("should ...")
  • Uses tracing macros (not println!)
  • New code has tests
  • No secrets or credentials committed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compression::from_content_encoding allocates String for case comparison

1 participant