Skip to content

Commit c0c06b7

Browse files
authored
fix: send proxy-authorization even with empty password (#2868)
1 parent a2aa5a3 commit c0c06b7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/proxy.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,8 @@ impl Proxy {
452452
}
453453

454454
fn cache_maybe_has_http_auth(url: &Url, extra: &Option<HeaderValue>) -> bool {
455-
url.scheme() == "http" && (url.password().is_some() || extra.is_some())
455+
url.scheme() == "http"
456+
&& (url.username().len() > 0 || url.password().is_some() || extra.is_some())
456457
}
457458

458459
fn cache_maybe_has_http_custom_headers(url: &Url, extra: &Option<HeaderMap>) -> bool {
@@ -917,6 +918,12 @@ mod tests {
917918
.unwrap()
918919
.into_matcher();
919920
assert!(m.maybe_has_http_auth(), "http forwards");
921+
922+
let m = Proxy::all("http://:in@yo.local").unwrap().into_matcher();
923+
assert!(m.maybe_has_http_auth(), "http forwards with empty username");
924+
925+
let m = Proxy::all("http://letme:@yo.local").unwrap().into_matcher();
926+
assert!(m.maybe_has_http_auth(), "http forwards with empty password");
920927
}
921928

922929
#[test]

0 commit comments

Comments
 (0)