PDA

View Full Version : problem while redirecting using qtnetworkreply



itskay007
19th September 2010, 15:00
i'm trying to get google calendar data from the account entered by user.
after authentication, the reply asks me to redirect to another page.

when redirecting to that page, it says your client made invalid request. The code is as follows:




QNetworkAccessManager *manager=new QNetworkAccessManager(this->parent());
QNetworkRequest request(QUrl("https://www.google.com/calendar/feeds/default/owncalendars/full"));
QString header="GoogleLogin auth="+auth;
request.setRawHeader("Authorization",header.toLocal8Bit());
QNetworkReply *reply=manager->get(request);
QEventLoop loop;
QObject::connect(reply,SIGNAL(finished()),&loop,SLOT(quit()));
loop.exec();
QUrl redir=reply->attribute(QNetworkRequest::RedirectionTargetAttrib ute).toUrl();
if(!redir.isEmpty())
{
QNetworkRequest req(redir);
req.setRawHeader("Authorization",header.toLocal8Bit());
reply=manager->get(req);
QObject::connect(reply,SIGNAL(finished()),&loop,SLOT(quit()));
loop.exec();
}
this->ui->textBrowser_2->setText(redir.toString());
this->ui->textBrowser->setText(reply->readAll());



Is this not how we handle redirections??