File tree 1 file changed +15
-11
lines changed
1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -129,26 +129,30 @@ impl CompressionEncoding {
129
129
return Ok ( None ) ;
130
130
} ;
131
131
132
- let header_value_str = if let Ok ( value) = header_value. to_str ( ) {
133
- value
134
- } else {
135
- return Ok ( None ) ;
136
- } ;
137
-
138
- match header_value_str {
132
+ match header_value. as_bytes ( ) {
139
133
#[ cfg( feature = "gzip" ) ]
140
- "gzip" if enabled_encodings. is_enabled ( CompressionEncoding :: Gzip ) => {
134
+ b "gzip" if enabled_encodings. is_enabled ( CompressionEncoding :: Gzip ) => {
141
135
Ok ( Some ( CompressionEncoding :: Gzip ) )
142
136
}
143
137
#[ cfg( feature = "zstd" ) ]
144
- "zstd" if enabled_encodings. is_enabled ( CompressionEncoding :: Zstd ) => {
138
+ b "zstd" if enabled_encodings. is_enabled ( CompressionEncoding :: Zstd ) => {
145
139
Ok ( Some ( CompressionEncoding :: Zstd ) )
146
140
}
147
- "identity" => Ok ( None ) ,
141
+ b "identity" => Ok ( None ) ,
148
142
other => {
143
+ // NOTE: Workaround for lifetime limitation. Resolved at Rust 1.79.
144
+ // https://blog.rust-lang.org/2024/06/13/Rust-1.79.0.html#extending-automatic-temporary-lifetime-extension
145
+ let other_debug_string;
146
+
149
147
let mut status = Status :: unimplemented ( format ! (
150
148
"Content is compressed with `{}` which isn't supported" ,
151
- other
149
+ match std:: str :: from_utf8( other) {
150
+ Ok ( s) => s,
151
+ Err ( _) => {
152
+ other_debug_string = format!( "{other:?}" ) ;
153
+ & other_debug_string
154
+ }
155
+ }
152
156
) ) ;
153
157
154
158
let header_value = enabled_encodings
You can’t perform that action at this time.
0 commit comments