VirtualBox

Changeset 43679 in vbox


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

iprt/http: introduced RTHttpSetProxy()

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/http.h

    r43645 r43679  
    7373RTR3DECL(int) RTHttpGet(RTHTTP hHttp, const char *pcszUrl, char **ppszResponse);
    7474
     75/**
     76 * Specify proxy settings.
     77 *
     78 * @returns iprt status code.
     79 *
     80 * @param    hHttp         HTTP interface handle.
     81 * @param    pcszProxy     URL of the proxy
     82 * @param    uPort         port number of the proxy, use 0 for not specifying a port.
     83 * @param    pcszUser      username, pass NULL for no authentication
     84 * @param    pcszPwd       password, pass NULL for no authentication
     85 */
     86RTR3DECL(int) RTHttpSetProxy(RTHTTP hHttp, const char *pcszProxyUrl, uint32_t uPort,
     87                             const char *pcszProxyUser, const char *pcszProxyPwd);
     88
    7589/** @} */
    7690
  • 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