PDA

View Full Version : QNetworkAccessManager's proxyAuthenticationRequired keep firing



sebtks
15th April 2011, 16:26
Hi All,

This is my first thread to the forum and below is a short description on what I'm trying to do:

I would to have my QWebView to work like browser that connect to internet, through proxy. Therefore, I use QNetworkAccessManager and use setNetworkAccessManager in QWebPage.
However, the proxyAuthenticationRequired signal keep firing even the correct username and password is provided. I have no idea what else I can do, and hopefully someone can help or give me some enlightenment.

Below is the simplified code:


/* main */
WebView* view = new WebView (this);
view->load(QUrl("http://www.mySite.com"));

WebView::WebView(QWidget *parent)
: QWebView(parent)
, m_page(new WebPage(this))
{
setPage(m_page);
}

WebPage::WebPage(QObject *parent)
: QWebPage(parent)
{
setNetworkAccessManager(/*networkAccessManager*/);
}

networkManager::networkManager(QWidget *parent)
: QNetworkAccessManager(parent)
{
connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)),
SLOT(authentication_required(QNetworkReply*,QAuthe nticator*)));

connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)),
SLOT(proxy_authentication_required(const QNetworkProxy&, QAuthenticator*)));

/* create and set proxy */
QNetworkProxy proxy(QNetworkProxy::HttpProxy,
"my-proxy",
8080,
user_name,
user_password);
setProxy(proxy);
}

void networkManager::proxy_authentication_required
(
const QNetworkProxy &proxy,
QAuthenticator *authenticator
)
{
/* create a dialog to allow user to type usename and password */

authenticator->setUser(/*username*/);
authenticator->setPassword(/*password*/);
}


I have an application that download file from a website across internet, behind proxy as well. I used QHttp (setHost() and get()) for the application and yet the proxyAuthenticationRequired is working fine.

I'm using Qt 4.7.0

Any advice on the problem described above is much appreciated.
Thanks in advance.