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

QNetworkAccessManager fails to work after proxy authentication cancelled( HTTP 407 error)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 4.7.4
    • Fix Version/s: 4.8.1, 5.0.0
    • Labels:
      None
    • Environment:
      windows xp
    • Commits:
      b6b862050039c53e5f9bb25b86047dd0335c0d81 (4.8), 4be2430925e04db1a998a11c1c281ae578feca4b (5.0)

      Description

      I am using the demo browser provided by Qt source and configure to use proxy server which requiring basic username/password authentication to access the internet.

      At first, an proxy authentication dialog has prompted as expected when tring to load webpage,however, I did not provide any information about username/password and I just click the "cancel" button. After that, the authentication dialog will never prompted again when I'm tring to load any other webpages ,so I will never get the chance to provide username/password again.

      I have examined the source code of demo browser as well as QtNetwork module, and find out the reason is after I cancelled the authentication dialog "proxyAuthenticationRequired" signal will never be emitted by QNetworkAccessManager. The suspicious code is as follows:

      void QNetworkAccessManagerPrivate::proxyAuthenticationRequired(QNetworkAccessBackend *backend,const QNetworkProxy &proxy,QAuthenticator *authenticator)
      {
          Q_Q(QNetworkAccessManager);
         
          if (proxy != backend->reply->lastProxyAuthentication) {
              QNetworkAuthenticationCredential *cred = fetchCachedCredentials(proxy);
              if (cred) {
                  authenticator->setUser(cred->user);
                  authenticator->setPassword(cred->password);
                  return;
              }
          }
      
          backend->reply->lastProxyAuthentication = proxy;
          emit q->proxyAuthenticationRequired(proxy, authenticator);
          addCredentials(proxy, authenticator);
      }
      
      

      In above code,emit "proxyAuthenticationRequired" signal will be bypassed when condition "proxy != backend->reply->lastProxyAuthentication" evaluates to true. My question is why this condition is true when authentication dialog has been cancelled?

      Can anybody tell me whether it is a QT bug ? And is there better practice to support HTTP proxy authentication?

      Thanks for your help!

        Attachments

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

          Activity

            People

            Assignee:
            shkearns Shane Kearns
            Reporter:
            chenmh chenminhua
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes