File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -270,4 +270,26 @@ mod test {
270
270
assert_eq ! ( accept. iter( ) . next( ) . unwrap( ) , Encoding :: Gzip ) ;
271
271
Ok ( ( ) )
272
272
}
273
+
274
+ #[ test]
275
+ fn iter ( ) -> crate :: Result < ( ) > {
276
+ let mut accept = AcceptEncoding :: new ( ) ;
277
+ accept. push ( Encoding :: Gzip ) ;
278
+ accept. push ( Encoding :: Brotli ) ;
279
+
280
+ let mut headers = Response :: new ( 200 ) ;
281
+ accept. apply ( & mut headers) ;
282
+
283
+ let accept = AcceptEncoding :: from_headers ( headers) ?. unwrap ( ) ;
284
+ let mut accept = accept. iter ( ) ;
285
+ assert_eq ! ( accept. next( ) . unwrap( ) , Encoding :: Gzip ) ;
286
+ assert_eq ! ( accept. next( ) . unwrap( ) , Encoding :: Brotli ) ;
287
+ Ok ( ( ) )
288
+ }
289
+ }
290
+
291
+ /// Order header proposals. In the case of two proposals of equal weight we pick
292
+ /// the one that was declared last.
293
+ fn sort_proposals < T : PartialOrd > ( props : & mut Vec < T > ) {
294
+ props. sort_unstable_by ( |a, b| a. partial_cmp ( b) . unwrap_or ( std:: cmp:: Ordering :: Less ) )
273
295
}
You can’t perform that action at this time.
0 commit comments