@@ -850,4 +850,58 @@ mod tests {
850
850
. await
851
851
. expect ( "GET request should succeed" ) ;
852
852
}
853
+
854
+ #[ tokio:: test]
855
+ async fn test_client_sends_accept_encoding_header_with_correct_values ( ) {
856
+ let ( aggregator, client) = setup_server_and_client ( ) ;
857
+ aggregator. mock ( |when, then| {
858
+ when. matches ( |req| {
859
+ let headers = req. headers . clone ( ) . expect ( "HTTP headers not found" ) ;
860
+ let accept_encoding_header = headers
861
+ . iter ( )
862
+ . find ( |( name, _values) | name. to_lowercase ( ) == "accept-encoding" )
863
+ . expect ( "Accept-Encoding header not found" ) ;
864
+
865
+ let header_value = accept_encoding_header. clone ( ) . 1 ;
866
+ [ "gzip" , "br" , "deflate" , "zstd" ]
867
+ . iter ( )
868
+ . all ( |& value| header_value. contains ( value) )
869
+ } ) ;
870
+
871
+ then. status ( 200 ) . body ( "ok" ) ;
872
+ } ) ;
873
+
874
+ client
875
+ . get_content ( AggregatorRequest :: ListCertificates )
876
+ . await
877
+ . expect ( "GET request should succeed with Accept-Encoding header" ) ;
878
+ }
879
+
880
+ #[ tokio:: test]
881
+ async fn test_client_with_custom_headers_sends_accept_encoding_header_with_correct_values ( ) {
882
+ let mut http_headers = HashMap :: new ( ) ;
883
+ http_headers. insert ( "Custom-Header" . to_string ( ) , "CustomValue" . to_string ( ) ) ;
884
+ let ( aggregator, client) = setup_server_and_client_with_custom_headers ( http_headers) ;
885
+ aggregator. mock ( |when, then| {
886
+ when. matches ( |req| {
887
+ let headers = req. headers . clone ( ) . expect ( "HTTP headers not found" ) ;
888
+ let accept_encoding_header = headers
889
+ . iter ( )
890
+ . find ( |( name, _values) | name. to_lowercase ( ) == "accept-encoding" )
891
+ . expect ( "Accept-Encoding header not found" ) ;
892
+
893
+ let header_value = accept_encoding_header. clone ( ) . 1 ;
894
+ [ "gzip" , "br" , "deflate" , "zstd" ]
895
+ . iter ( )
896
+ . all ( |& value| header_value. contains ( value) )
897
+ } ) ;
898
+
899
+ then. status ( 200 ) . body ( "ok" ) ;
900
+ } ) ;
901
+
902
+ client
903
+ . get_content ( AggregatorRequest :: ListCertificates )
904
+ . await
905
+ . expect ( "GET request should succeed with Accept-Encoding header" ) ;
906
+ }
853
907
}
0 commit comments