VirtualBox

Ignore:
Timestamp:
Oct 18, 2012 12:26:04 PM (12 years ago)
Author:
vboxsync
Message:

iprt/http: introduced RTHttpSetProxy()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/http.cpp

    r43651 r43679  
    137137}
    138138
     139RTR3DECL(int) RTHttpSetProxy(RTHTTP hHttp, const char *pcszProxy, uint32_t uPort,
     140                             const char *pcszProxyUser, const char *pcszProxyPwd)
     141{
     142    PRTHTTPINTERNAL pHttpInt = hHttp;
     143    RTHTTP_VALID_RETURN(pHttpInt);
     144    AssertPtrReturn(pcszProxy, VERR_INVALID_PARAMETER);
     145
     146    int rcCurl = curl_easy_setopt(pHttpInt->pCurl, CURLOPT_PROXY, pcszProxy);
     147    if (CURL_FAILED(rcCurl))
     148        return VERR_INVALID_PARAMETER;
     149
     150    if (uPort != 0)
     151    {
     152        rcCurl = curl_easy_setopt(pHttpInt->pCurl, CURLOPT_PROXYPORT, (long)uPort);
     153        if (CURL_FAILED(rcCurl))
     154            return VERR_INVALID_PARAMETER;
     155    }
     156
     157    if (pcszProxyUser && pcszProxyPwd)
     158    {
     159        rcCurl = curl_easy_setopt(pHttpInt->pCurl, CURLOPT_PROXYUSERNAME, pcszProxyUser);
     160        if (CURL_FAILED(rcCurl))
     161            return VERR_INVALID_PARAMETER;
     162
     163        rcCurl = curl_easy_setopt(pHttpInt->pCurl, CURLOPT_PROXYPASSWORD, pcszProxyPwd);
     164        if (CURL_FAILED(rcCurl))
     165            return VERR_INVALID_PARAMETER;
     166    }
     167
     168    return VINF_SUCCESS;
     169}
     170
    139171RTR3DECL(int) RTHttpGet(RTHTTP hHttp, const char *pcszUrl, char **ppszResponse)
    140172{
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