VirtualBox

Ignore:
Timestamp:
Sep 20, 2018 12:37:23 AM (6 years ago)
Author:
vboxsync
Message:

IPRT/http: Added RTHttpSetProxyByUrl, deprecating RTHttpSetProxy in favor of it. bugref:9248

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/generic/http-curl.cpp

    r74370 r74377  
    575575        AssertMsgReturn(rcCurl == CURLE_OK, ("CURLOPT_PROXYTYPE=%d: %d (%#x)\n", enmProxyType, rcCurl, rcCurl),
    576576                        VERR_HTTP_CURL_PROXY_CONFIG);
    577         pThis->enmProxyType = CURLPROXY_HTTP;
     577        pThis->enmProxyType = enmProxyType;
    578578    }
    579579
     
    829829            char    *pszPassword = RTUriParsedAuthorityPassword(pszProxyUrl, &Parsed);
    830830            uint32_t uProxyPort  = RTUriParsedAuthorityPort(pszProxyUrl, &Parsed);
     831            bool     fUnknownProxyType = false;
    831832            curl_proxytype enmProxyType;
    832833            if (RTUriIsSchemeMatch(pszProxyUrl, "http"))
     
    836837                    uProxyPort = 80;
    837838            }
     839#if CURL_AT_LEAST_VERSION(7,52,0)
     840            else if (RTUriIsSchemeMatch(pszProxyUrl, "https"))
     841            {
     842                enmProxyType  = CURLPROXY_HTTPS;
     843                if (uProxyPort == UINT32_MAX)
     844                    uProxyPort = 443;
     845            }
     846#endif
    838847            else if (   RTUriIsSchemeMatch(pszProxyUrl, "socks4")
    839848                     || RTUriIsSchemeMatch(pszProxyUrl, "socks"))
     
    847856            else
    848857            {
     858                fUnknownProxyType = true;
    849859                enmProxyType = CURLPROXY_HTTP;
    850860                if (uProxyPort == UINT32_MAX)
     
    857867
    858868            rc = rtHttpUpdateProxyConfig(pThis, enmProxyType, pszHost, uProxyPort, pszUsername, pszPassword);
     869            if (RT_SUCCESS(rc) && fUnknownProxyType)
     870                rc = VWRN_WRONG_TYPE;
    859871
    860872            RTStrFree(pszUsername);
     
    871883        RTMemTmpFree(pszFreeMe);
    872884    return rc;
     885}
     886
     887
     888RTR3DECL(int) RTHttpSetProxyByUrl(RTHTTP hHttp, const char *pszUrl)
     889{
     890    PRTHTTPINTERNAL pThis = hHttp;
     891    RTHTTP_VALID_RETURN(pThis);
     892    AssertPtrNullReturn(pszUrl, VERR_INVALID_PARAMETER);
     893    AssertReturn(!pThis->fBusy, VERR_WRONG_ORDER);
     894
     895    if (!pszUrl || !*pszUrl)
     896        return RTHttpUseSystemProxySettings(pThis);
     897    if (RTStrNICmpAscii(pszUrl, RT_STR_TUPLE("direct://")) == 0)
     898        return rtHttpUpdateAutomaticProxyDisable(pThis);
     899    return rtHttpConfigureProxyFromUrl(pThis, pszUrl);
    873900}
    874901
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette