Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.7.4
-
None
-
windows xp
-
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!