Is it true that QNetworkAccessManager has no built-in support for http redirection?
I would like to download raw html from the Internet but it seems that I can't get to the final redirected webpage.
#ifndef PROGRAM_H
#define PROGRAM_H
#include <QtNetwork>
#include <QtCore>
{
Q_OBJECT
public:
Program()
{
net = 0;
}
~Program()
{
delete net;
}
void run()
{
net = new QNetworkAccessManager;
connect(net, SIGNAL(finished(QNetworkReply*)),this, SLOT(replyFinished(QNetworkReply*)));
net
->get
(QNetworkRequest
(QUrl("http://www.yahoo.com")));
}
private slots:
void replyFinished(QNetworkReply* r){
qDebug() << s;
}
private :
QNetworkAccessManager* net;
};
#endif // PROGRAM_H
#ifndef PROGRAM_H
#define PROGRAM_H
#include <QtNetwork>
#include <QtCore>
class Program : public QObject
{
Q_OBJECT
public:
Program()
{
net = 0;
}
~Program()
{
delete net;
}
void run()
{
net = new QNetworkAccessManager;
connect(net, SIGNAL(finished(QNetworkReply*)),this, SLOT(replyFinished(QNetworkReply*)));
net->get(QNetworkRequest(QUrl("http://www.yahoo.com")));
}
private slots:
void replyFinished(QNetworkReply* r){
QString s = r->readAll();
qDebug() << s;
}
private :
QNetworkAccessManager* net;
};
#endif // PROGRAM_H
To copy to clipboard, switch view to plain text mode
When run it called, I got the following:
<!-- w84.fp.sk1.yahoo.com uncompressed/chunked Thu Jul 7 08:37:01 PDT 2011 -->
<!-- w84.fp.sk1.yahoo.com uncompressed/chunked Thu Jul 7 08:37:01 PDT 2011 -->
To copy to clipboard, switch view to plain text mode
instead of the final redirected webpage.
Bookmarks