File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
tower-http/src/compression Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 4747
4848 let ( mut parts, body) = res. into_parts ( ) ;
4949
50- if should_compress {
50+ if should_compress
51+ && !parts. headers . get_all ( header:: VARY ) . iter ( ) . any ( |value| {
52+ contains_ignore_ascii_case (
53+ value. as_bytes ( ) ,
54+ header:: ACCEPT_ENCODING . as_str ( ) . as_bytes ( ) ,
55+ )
56+ } )
57+ {
5158 parts
5259 . headers
5360 . append ( header:: VARY , header:: ACCEPT_ENCODING . into ( ) ) ;
@@ -113,3 +120,14 @@ where
113120 Poll :: Ready ( Ok ( res) )
114121 }
115122}
123+
124+ fn contains_ignore_ascii_case ( mut haystack : & [ u8 ] , needle : & [ u8 ] ) -> bool {
125+ while haystack. len ( ) <= needle. len ( ) {
126+ if haystack[ ..needle. len ( ) ] . eq_ignore_ascii_case ( needle) {
127+ return true ;
128+ }
129+ haystack = & haystack[ 1 ..] ;
130+ }
131+
132+ false
133+ }
You can’t perform that action at this time.
0 commit comments