HTTP Proxy Property

By default, a new RHTTPSession is set to make direct connections to an origin server. To switch it to use a proxy, the following two properties must be set: HTTP::EProxyUsage and HTTP::EProxyAddress .

  • HTTP::EProxyUsage can take the values HTTP::EDoNotUseProxy (the default) or HTTP::EUseProxy .

  • HTTP::EProxyAddress must be set using an RStringF value that contains the proxy address as an IP Address and port number separated by a colon, for example, "10.158.7.4:9003".

      
       
      
      void CHttpClient::SetProxyL(RStringF aProxyAddr)
    {
    RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
    THTTPHdrVal proxyUsage(iSess.StringPool().StringF(HTTP::EUseProxy,RHTTPSession::GetTable()));
    connInfo.SetPropertyL(iSess.StringPool().StringF(HTTP::EProxyUsage,RHTTPSession::GetTable()), proxyUsage);

    THTTPHdrVal proxyAddr(aProxyAddr);
    connInfo.SetPropertyL(iSess.StringPool().StringF(HTTP::EProxyAddress,RHTTPSession::GetTable()), aProxyAddr);

    Printf(_L("Proxy set to:%S\n\n"), &iProxyName);
    }
     

Changes made to the proxy settings will affect only new transactions opened on the session, and not any currently in progress.

Transaction proxy properties

A proxy setting can be set for an individual transaction by setting the proxy properties on the transaction. Proxy properties set on the transaction override any proxy properties set on the session.