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 47
47
48
48
let ( mut parts, body) = res. into_parts ( ) ;
49
49
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
+ {
51
58
parts
52
59
. headers
53
60
. append ( header:: VARY , header:: ACCEPT_ENCODING . into ( ) ) ;
@@ -113,3 +120,14 @@ where
113
120
Poll :: Ready ( Ok ( res) )
114
121
}
115
122
}
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