QNetworkProxy: No use of proxy for specified Adresses?



  • Hi

    I have to set a QNetworkProxy to get connection to the Internet from my system. However, I also have a UPnP-server on my local system, which gives me Pictures via http-Protocol. Unfortunatly, it does not use 127.0.0.1 as adress, but the real IP-adress of my local PC(let's say the adress of that PC is 192.168.0.8)

    There is no way to change this server, because I do not have the source code.

    Is there a way to tell QNetworkProxy to ignore the proxy for a specific adress? (Like the setting in Firefox, where you can define "No proxy for")

    My current code is

    @ QString urlEnv = QProcessEnvironment::systemEnvironment().value("http_proxy");
    if (!urlEnv.isEmpty())
    {
    QUrl url = QUrl(urlEnv, QUrl::TolerantMode);
    QNetworkProxy proxy;
    proxy.setType(QNetworkProxy::HttpProxy);
    proxy.setHostName(url.host());
    proxy.setPort(url.port(8080));
    QNetworkProxy::setApplicationProxy(proxy);
    }
    @

    I'm searching for something like

    proxy.ignoreProxyFor("192.168.0.8")

    I have to say I'm not at all an expert in network communication, I touched this only because othwise I had no change that my program is connected to the outside world



  • The API does not seem to have such an option. If you are using QTcpSocket directly, you can use @socket->setProxy(QNetworkProxy::NoProxy);@ before connecting. If you use QNetworkAccessManager, I can't think of a proper solution.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.