Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-39715

Add support for chaining QNetworkProxy instances via HTTP CONNECT (RFC 2817)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.3.0
    • Fix Version/s: Some future release
    • Component/s: Network: Proxies
    • Labels:
      None
    • Environment:
      Any

      Description

      There is currently no way of using HTTP CONNECT method as
      defined by RFC 2817 (http://www.ietf.org/rfc/rfc2817.txt)
      with QNetworkAccessManager.

      You can do that with QTcpSocket but even then it's akward
      (quick & dirty code example without error checking below)

          this->socket->connectToHost("220.133.5.108",3128);
          qDebug() << "Connecting to " << this->socket->peerName();
          if(this->socket->waitForConnected()) {
              qDebug() << "OK!";
      
              QByteArray verb  = "CONNECT 86.51.26.16:8080 HTTP/1.1\r\nHost: 86.51.26.16\r\n\r\n";
      
              qDebug() << verb;
              this->socket->write(verb);
              if(this->socket->waitForBytesWritten()) {
                  qDebug() << "OK!";
                  if(this->socket->waitForReadyRead()) {
                      qDebug() << this->socket->readAll();
                  qDebug() << "GET http://en.wikipedia.org/wiki/Main_Page HTTP/1.1";
                  this->socket->write("GET http://en.wikipedia.org/wiki/Main_Page HTTP/1.1\r\n\r\n");
                  if(this->socket->waitForBytesWritten()) {
                      qDebug() << "OK!";
                      if(this->socket->waitForReadyRead()) {
                          qDebug() << this->socket->readAll();
                      }
                  }
                  }
              }
      
          }
      
      

      Please add a way to set HTTP CONNECT method (http://www.ietf.org/rfc/rfc2817.txt)
      with QNetworkProxy so that QNetworkAccessManager can then use it by
      simple setting it with setProxy().

      There could be a static class function to create the proxy chain like this:

      QNetworkProxy	QNetworkProxy::createProxyChain(const QList<QNetworkProxy>& proxies);
      

      And then it could be used like this:

      QList<QNetworkProxy>	proxies;
      			proxies.append(QNetworkProxy(QNetworkProxy::HttpProxy,"220.133.5.108",3128));
      			proxies.append(QNetworkProxy(QNetworkProxy::HttpProxy,"86.51.26.16",8080));
      
      QNetworkProxy	proxy = QNetworkProxy::createProxyChain(proxies);
      
      
      QNetworkAccessManager	manager;
      			manager.setProxy(proxy); // <---- Sets to use the first proxy (220.133.5.108:3128) in the chain
      						 //       servers however will see the last in the chain, in this case
      						 //	  86.51.26.16:8080
      
      

      )

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              cnn Qt Core & Network
              Reporter:
              crazythinker Stefan Fröberg
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:

                Gerrit Reviews

                There are no open Gerrit changes