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

Network proxy cache is broken

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 4.7.0
    • Fix Version/s: None
    • Component/s: Network: Proxies
    • Labels:
      None

      Description

      The attached example demonstrates the problem. It has been reproduced using Windows and Linux.

      When using the following piece of code where username/password is set in the proxy object, everything works fine:

      QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, "someHostName",somePort, "someUserName", "somePassword"));

      However, if the code is changed to:

      QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, "someHostName", somePort));

      without passing username/password, and a dialog is popped up to get the username and password and pass it to the QAuthenticator as shown below then it does not work:

      void HttpWindow::slotProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator* authenticator) {
      QDialog dlg;
      Ui::Dialog ui;
      ui.setupUi(&dlg);
      dlg.adjustSize();
      ui.siteDescription->setText(tr("%1 at %2").arg(authenticator->realm()).arg(url.host()));
      
      if (dlg.exec() == QDialog::Accepted) {
      authenticator->setUser(ui.userEdit->text());
      authenticator->setPassword(ui.passwordEdit->text());
      }
      }

      These lines are shown in the output:

      QNetworkAccessCache::addEntry: overriding active cache entry 'auth:proxy-http://...
      QNetworkAccessCache::addEntry: overriding active cache entry 'auth:proxy-http://...
      QNetworkAccessCache::addEntry: overriding active cache entry 'auth:proxy-http://...'

      It can be fixed as follows:

      void HttpWindow::slotProxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator* authenticator) {
      QDialog dlg;
      Ui::Dialog ui;
      ui.setupUi(&dlg);
      dlg.adjustSize();
      ui.siteDescription->setText(tr("%1 at %2").arg(authenticator->realm()).arg(url.host()));
      
      if (dlg.exec() == QDialog::Accepted) {
      authenticator->setUser(ui.userEdit->text());
      authenticator->setPassword(ui.passwordEdit->text());
      QNetworkProxy p(proxy);
      p.setUser(ui.userEdit->text());
      p.setPassword(ui.passwordEdit->text());
      QNetworkProxy::setApplicationProxy(p);
      }

      }

      but that's a dirty hack ...

        Attachments

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

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            naevdal Sigrid Fjell Nævdal (Inactive)
            Votes:
            4 Vote for this issue
            Watchers:
            10 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes