@@ -2,6 +2,7 @@ use std::error::Error;
22use std:: fmt;
33use std:: sync:: Arc ;
44
5+ use http:: uri:: Scheme ;
56use http:: { header:: HeaderValue , HeaderMap , Uri } ;
67use hyper_util:: client:: proxy:: matcher;
78
@@ -452,12 +453,12 @@ impl Proxy {
452453}
453454
454455fn cache_maybe_has_http_auth ( url : & Url , extra : & Option < HeaderValue > ) -> bool {
455- url. scheme ( ) == "http"
456+ ( url. scheme ( ) == "http" || url . scheme ( ) == "https" )
456457 && ( url. username ( ) . len ( ) > 0 || url. password ( ) . is_some ( ) || extra. is_some ( ) )
457458}
458459
459460fn cache_maybe_has_http_custom_headers ( url : & Url , extra : & Option < HeaderMap > ) -> bool {
460- url. scheme ( ) == "http" && extra. is_some ( )
461+ ( url. scheme ( ) == "http" || url . scheme ( ) == "https" ) && extra. is_some ( )
461462}
462463
463464impl fmt:: Debug for Proxy {
@@ -551,7 +552,8 @@ impl Matcher {
551552
552553 pub ( crate ) fn http_non_tunnel_basic_auth ( & self , dst : & Uri ) -> Option < HeaderValue > {
553554 if let Some ( proxy) = self . intercept ( dst) {
554- if proxy. uri ( ) . scheme_str ( ) == Some ( "http" ) {
555+ let scheme = proxy. uri ( ) . scheme ( ) ;
556+ if scheme == Some ( & Scheme :: HTTP ) || scheme == Some ( & Scheme :: HTTPS ) {
555557 return proxy. basic_auth ( ) . cloned ( ) ;
556558 }
557559 }
@@ -565,7 +567,8 @@ impl Matcher {
565567
566568 pub ( crate ) fn http_non_tunnel_custom_headers ( & self , dst : & Uri ) -> Option < HeaderMap > {
567569 if let Some ( proxy) = self . intercept ( dst) {
568- if proxy. uri ( ) . scheme_str ( ) == Some ( "http" ) {
570+ let scheme = proxy. uri ( ) . scheme ( ) ;
571+ if scheme == Some ( & Scheme :: HTTP ) || scheme == Some ( & Scheme :: HTTPS ) {
569572 return proxy. custom_headers ( ) . cloned ( ) ;
570573 }
571574 }
@@ -912,7 +915,7 @@ mod tests {
912915 let m = Proxy :: all ( "https://letme:in@yo.local" )
913916 . unwrap ( )
914917 . into_matcher ( ) ;
915- assert ! ( ! m. maybe_has_http_auth( ) , "https always tunnels " ) ;
918+ assert ! ( m. maybe_has_http_auth( ) , "https forwards " ) ;
916919
917920 let m = Proxy :: all ( "http://letme:in@yo.local" )
918921 . unwrap ( )
0 commit comments