Use proxy credentials preemptively too in wxWebRequestCURL

Extend the changes of 2be7895e8a (Add support for preemptively using
"Basic" HTTP authentication, 2025-12-22) to proxy credentials as well.

Currently this is only implemented for libcurl backend.
This commit is contained in:
Vadim Zeitlin
2026-04-13 19:57:27 +02:00
parent 20297a8379
commit fb261c56b5
2 changed files with 25 additions and 0 deletions
+8
View File
@@ -493,6 +493,10 @@ public:
Execute(): this will use the provided credentials for the initial
request.
Note that when using a proxy with credentials information, proxy
credentials will be also included in the initial request if this
function is called when using libcurl backend.
@since 3.3.2
*/
void UseBasicAuth(const wxWebCredentials& cred);
@@ -1001,6 +1005,10 @@ public:
Execute(): this will use the provided credentials for the initial
request.
Note that when using a proxy with credentials information, proxy
credentials will be also included in the initial request if this
function is called when using libcurl backend.
@since 3.3.2
*/
void UseBasicAuth(const wxWebCredentials& cred);
+17
View File
@@ -548,6 +548,23 @@ wxWebRequest::Result wxWebRequestCURL::DoFinishPrepare()
basicAuthCred.GetUser());
wxCURLSetOpt(m_handle, CURLOPT_PASSWORD,
basicAuthCred.GetPassword().GetAsString());
const wxWebProxy& proxy = GetSessionImpl().GetProxy();
if ( proxy.GetType() == wxWebProxy::Type::URL )
{
// If we're using proxy, we should set credentials for it too,
// otherwise we'd still use more than one request.
const wxURI proxyURL(proxy.GetURL());
if ( proxyURL.HasUserInfo() )
{
wxCURLSetOpt(m_handle, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
wxCURLSetOpt(m_handle, CURLOPT_PROXYUSERNAME,
proxyURL.GetUser());
wxCURLSetOpt(m_handle, CURLOPT_PROXYPASSWORD,
proxyURL.GetPassword());
}
}
}
wxCURLSetOpt(m_handle, CURLOPT_HTTPAUTH, httpAuthMethod);