QTNetwork proxyAuthenticationRequired fires only "once"
In a networking application I have an Options dialog where a proxy server credentials can be entered, if we happen to be in an environment where a proxy server requires authentication.
Secondly, all download code uses a wrapper class which in turn calls the QNetworkProxyFactory::systemProxyForQuery before starting any downloads to resolve are we behind a proxy. This wrapper class then calls setUser and setPassword methods to all of the QNetworkProxy objects returned by the call to systemProxyForQuery if the credentials happen to exist in the "Options dialog" mentioned earlier.
This download code also connects the signal QNetworkAccessManager::proxyAuthenticationRequired to display an error dialog, if these user entered credentials are not inputted or are in fact incorrect (starting the app 1st time etc.).
All of this works quite ok in various different networking conditions, but I have the following problem. Let's say for example that the proxyAuthenticationRequired signal fires, and I then present a dialog to input the new valid proxy server credentials, and they are set to the QAuthenticator object successfully and some downloads succeed as a result. If I now go to the options dialog again and remove the username and password there, the following proxies discovered by the systemProxyForQuery are not filled with the correct credentials required by the proxy server. As a result, I get a LOT of traffic from Qt and tons of Http 407 proxy authentication required replies (I'm monitoring this with WireShark), but in fact the QNetworkAccessManager::proxyAuthenticationRequired signal is not fired, and I find it very difficult to programmatically discover this state. None of the brakepoints in "my code" are hit etc, and yet, there are like 10000 to 20000 http packets being sent to and received from the proxy server, before the qnetwork module goes silent.
I realize this is not the most valid use case, even in my application, but I was wondering if anyone could have an idea how could I detect the "proxyAuthenticationRequired" the second time (or when those credentials are changed again on-the-fly)?
I'm also wondering whether my approach to resolving proxies and their authentication preferences is somehow flawed in design. Should I perhaps trust the proxyAuthenticationRequired signal more and discard the entire wrapper code that "auto fills" the proxy credentials for the systemProxyForQuery results?
My environment for the moment is Qt 4.7.1 commercial, and Windows OS'es.
Any insight on the matter would be much appreciated thanks!