@@ -71,6 +71,48 @@ async fn http_proxy_basic_auth() {
7171 assert_eq ! ( res. status( ) , reqwest:: StatusCode :: OK ) ;
7272}
7373
74+ #[ tokio:: test]
75+ async fn http_proxy_does_not_use_later_proxy_basic_auth ( ) {
76+ http_proxy_does_not_use_later_proxy_headers ( false ) . await ;
77+ }
78+
79+ #[ tokio:: test]
80+ async fn http_proxy_does_not_use_later_proxy_custom_headers ( ) {
81+ http_proxy_does_not_use_later_proxy_headers ( true ) . await ;
82+ }
83+
84+ async fn http_proxy_does_not_use_later_proxy_headers ( custom : bool ) {
85+ let url = "http://hyper.rs.local/prox" ;
86+ let server = server:: http ( move |req| {
87+ assert ! ( !req. headers( ) . contains_key( "proxy-authorization" ) ) ;
88+ assert ! ( !req. headers( ) . contains_key( "x-proxy-secret" ) ) ;
89+
90+ async { http:: Response :: default ( ) }
91+ } ) ;
92+
93+ let later_proxy = reqwest:: Proxy :: http ( "http://unused.proxy.local" ) . unwrap ( ) ;
94+ let later_proxy = if custom {
95+ let mut headers = reqwest:: header:: HeaderMap :: new ( ) ;
96+ headers. insert ( "proxy-authorization" , "secret" . parse ( ) . unwrap ( ) ) ;
97+ headers. insert ( "x-proxy-secret" , "secret" . parse ( ) . unwrap ( ) ) ;
98+ later_proxy. headers ( headers)
99+ } else {
100+ later_proxy. basic_auth ( "Aladdin" , "open sesame" )
101+ } ;
102+
103+ let res = reqwest:: Client :: builder ( )
104+ . proxy ( reqwest:: Proxy :: http ( format ! ( "http://{}" , server. addr( ) ) ) . unwrap ( ) )
105+ . proxy ( later_proxy)
106+ . build ( )
107+ . unwrap ( )
108+ . get ( url)
109+ . send ( )
110+ . await
111+ . unwrap ( ) ;
112+
113+ assert_eq ! ( res. status( ) , reqwest:: StatusCode :: OK ) ;
114+ }
115+
74116#[ tokio:: test]
75117async fn http_proxy_basic_auth_parsed ( ) {
76118 let url = "http://hyper.rs.local/prox" ;
0 commit comments