Hi all,
I am developing an application that uses the Qt Webkit. I have this code :
void SignalHandler::ddlogin()
{
Manager = new QNetworkAccessManager();
QObject::connect(Manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(finished_login(QNetworkReply *)));
QNetworkRequest request;
request.setUrl(QUrl("http://ddunlimited.net/ucp.php?mode=login"));
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/x-www-form-urlencoded"));
request.setRawHeader("User-Agent", "Firefox/3.0.10");
QUrl params;
params.addQueryItem("username", *(Config->get_user_forum()) );
params.addQueryItem("password", *(Config->get_pass_forum()));
params.addQueryItem("redirect","index.php");
params.addQueryItem("login", "Login");
params.encodedQuery();
QNetworkReply *test = Manager->post(request,params.encodedQuery());
}
void SignalHandler::finished_login(QNetworkReply *reply)
{
QObject::disconnect(Manager, SIGNAL(finished(QNetworkReply *)),this,SLOT(finished_login(QNetworkReply *)));
QByteArray *temp = new QByteArray(reply->readAll());
QFile file("temp.html");
file.open(QIODevice::WriteOnly);
file.write(*temp);
file.close();
}
This code should make the login in forums based on phpbb3. It works for several forums, but it doesn’t work for a forum. The problem is that the reply->readAll() return an empty QByteArray. The same code works for others forum, and it returns the html page after the login.
I tried to debug the problem with a network analyzer and I saw that the server responds with the http response status code 302. It seems a sort of redirect, but I’m not sure. How can I handle this ? Is there a workaround ? Sorry for my english and sorry for my lack of experience.
Kind regards,
Stefano.
↧