File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -286,6 +286,22 @@ mod test {
286
286
assert_eq ! ( accept. next( ) . unwrap( ) , Encoding :: Brotli ) ;
287
287
Ok ( ( ) )
288
288
}
289
+
290
+ #[ test]
291
+ fn reorder_iter_based_on_weight ( ) -> crate :: Result < ( ) > {
292
+ let mut accept = AcceptEncoding :: new ( ) ;
293
+ accept. push ( EncodingProposal :: new ( Encoding :: Gzip , Some ( 0.4 ) ) ?) ;
294
+ accept. push ( EncodingProposal :: new ( Encoding :: Brotli , Some ( 0.8 ) ) ?) ;
295
+
296
+ let mut headers = Response :: new ( 200 ) ;
297
+ accept. apply ( & mut headers) ;
298
+
299
+ let accept = AcceptEncoding :: from_headers ( headers) ?. unwrap ( ) ;
300
+ let mut accept = accept. iter ( ) ;
301
+ assert_eq ! ( accept. next( ) . unwrap( ) , Encoding :: Brotli ) ;
302
+ assert_eq ! ( accept. next( ) . unwrap( ) , Encoding :: Gzip ) ;
303
+ Ok ( ( ) )
304
+ }
289
305
}
290
306
291
307
/// Order header proposals. In the case of two proposals of equal weight we pick
You can’t perform that action at this time.
0 commit comments