Proxy and QTcpSockets



  • Hello all,
    I have a QTcpSocket, which send data in HTTP protocol (manualy building HTTP header). And now I need to make proxy support.
    How to do this?



  • Connect to the proxy instead of the actual host and do the correct protocol handshake etc.pp. There is nothing special regarding Qt in this area.

    BTW: why do you implement your own HTTP protocol handler using QTcpSocket? There's QNetworkAccessManager with a fine HTTP implementation. Or use some of the other libs out there (eg. curl or neon).



  • For example from assistant:

    @QNetworkProxy proxy;
    proxy.setType(QNetworkProxy::Socks5Proxy);
    proxy.setHostName("proxy.example.com");
    proxy.setPort(1080);
    proxy.setUser("username");
    proxy.setPassword("password");

    socket->setProxy(proxy);
    @

    or you can install proxy for all application connection:

    @QNetworkProxy::setApplicationProxy(proxy);@



  • why do you implement your own HTTP protocol handler using QTcpSocket? There’s QNetworkAccessManager with a fine HTTP implementation. Or use some of the other libs out there (eg. curl or neon).
    I develop a small proxy server... And I need to work directly with http headers...

    For example from assistant:
    I did it like in this sample, but it doesn't work for example at youtube...



  • If you do implement your own proxy, the example from assistant is of course nothing that can help you in this case.

    If you work with QTcpSocket you must implement the HTTP and the proxy additions completely from scratch.



  • ok. The problem was solved. I just used QNetworkProxy, and a bit code for support at mine proxy.


Log in to reply
 

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