tower-rs / tower-http

HTTP specific Tower utilities.
675 stars 156 forks source link

Support x-gzip as Accept-Encoding in Compression (#466) #467

Closed privettoli closed 6 months ago

privettoli commented 6 months ago

Implements #466

Motivation

From #466

As developers migrate existing applications to Rust, ensuring seamless backward compatibility is crucial. Many of these applications already recognize "x-gzip" as a valid encoding for gzip. Adhering to RFC9110, which advises treating "x-gzip" as synonymous with "gzip", we can facilitate a smoother transition for these applications. This change streamlines the migration process and ensures that our Rust-based solutions remain backward compatible, fostering wider adoption and minimizing potential integration issues.

Solution

Added || s.eq_ignore_ascii_case("x-gzip") to content_encoding.rs:64 with additional tests: 1. Should compress response with gzip And return content-type: gzip When accept-encoding is x-gzip 2. Should compress response with gzip When accept-encoding has both x-gzip and deflate (to test that it's treated the same as gzip for ordering)

privettoli commented 6 months ago

CI failures are due to changes in https://github.com/EmbarkStudios/cargo-deny-action/issues/73

privettoli commented 6 months ago

After fixing the CI action, the checks pass.