mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-17 10:59:39 +00:00
Send proxy Basic authentication when one credential is empty
Proxy-Authorization was added only when both the proxy username and the proxy password were set, and a cross-host redirect carried the proxy credentials over only when the username was set. Authorization has been sent when either one is set since #958; do the same for the proxy. A client that has both a proxy Basic credential with one empty field and a proxy bearer token now sends Basic rather than Bearer, the order Authorization already follows.
This commit is contained in:
1 parent
11daa99c86
commit
941745c33d
2 files changed
+37
-3
No files matched your search
@@ -15944,7 +15944,8 @@ inline void ClientImpl::setup_redirect_client(ClientType &client) {
|
||||
if (!proxy_host_.empty() && proxy_port_ != -1) {
|
||||
client.set_proxy(proxy_host_, proxy_port_);
|
||||
|
||||
if (!proxy_basic_auth_username_.empty()) {
|
||||
if (!proxy_basic_auth_username_.empty() ||
|
||||
!proxy_basic_auth_password_.empty()) {
|
||||
client.set_proxy_basic_auth(proxy_basic_auth_username_,
|
||||
proxy_basic_auth_password_);
|
||||
}
|
||||
@@ -16047,8 +16048,8 @@ inline bool ClientImpl::write_request(Stream &strm, Request &req,
|
||||
// otherwise NO_PROXY-matched requests, and requests inside a TLS tunnel,
|
||||
// would leak proxy credentials to the destination server.
|
||||
if (is_proxy_enabled_for_host(host_) && (!is_ssl() || is_connect)) {
|
||||
if (!proxy_basic_auth_username_.empty() &&
|
||||
!proxy_basic_auth_password_.empty() &&
|
||||
if ((!proxy_basic_auth_username_.empty() ||
|
||||
!proxy_basic_auth_password_.empty()) &&
|
||||
!req.has_header("Proxy-Authorization")) {
|
||||
req.headers.insert(make_basic_authentication_header(
|
||||
proxy_basic_auth_username_, proxy_basic_auth_password_, true));
|
||||
|
||||
Reference in new issue
Block a user