Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Proxy and QTcpSockets
QtWS25 Last Chance

Proxy and QTcpSockets

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 6.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DmT021
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      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).

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vsorokin
        wrote on last edited by
        #3

        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);@

        --
        Vasiliy

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DmT021
          wrote on last edited by
          #4

          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...

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            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.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DmT021
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved