[Qt-interest] qwebview post operation with authentication
Fabien Brachere
fabien at brachere.net
Tue Apr 28 09:02:32 CEST 2009
Hi all,
it seems that QWebView has a problem to download a web page when you
make a post operation with authentication.
The code I used (with Qt 4.4.3 and Qt 4.5.1):
---------------------------------------------------
#include <QApplication>
#include <QWebView>
#include <QNetworkRequest>
int main (int argc, char **argv)
{
QApplication app(argc,argv);
QWebView *wView = new QWebView(0);
QByteArray postVars = QByteArray(QString("foo=bar").toAscii());
QUrl url("http://a_web_page/with/authorization/index.php");
url.setUserName("the_user");
url.setPassword("the_pass");
QNetworkRequest nR = QNetworkRequest(url);
//wView->load(nR,QNetworkAccessManager::GetOperation);
wView->load(nR,QNetworkAccessManager::PostOperation,postVars);
wView->show();
app.exec();
}
----------------------------------------------------
I test it on a Apache webserver with this .htaccess file:
AuthUserFile /root/protect/users
AuthName "Test"
AuthType Basic
<Limit GET POST>
require user the_user
</Limit>
When you replace the PostOperation by GetOperation, it works as
expected.
I used a network sniffer and see that the last request (after the 401
response from the server) is not finished (no post vars).
If you make a second QWebView::load, it works...
Is it a bug in Qt or I did something wrong ?
Thanks.
More information about the Qt-interest-old
mailing list