1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-23 10:42:11 +02:00
falkonOfficial/src/tools/followredirectreply.cpp
nowrep 2cb067878d Coding style, fixed cppcheck warnings + improved html highlighter
- html highlighter is now highlighting with reg exps, no more with hard
coded tags/tag options
 - all cppecheck warnings fixed + added script (cppcheck.sh)
 - introduced coding style + added astyle script (coding_style.sh)
 - fixed one mistake in czech translate + updated windows installer
2011-11-06 17:01:23 +01:00

35 lines
983 B
C++

#include "followredirectreply.h"
FollowRedirectReply::FollowRedirectReply(const QUrl &url, QNetworkAccessManager* manager)
: QObject()
, m_manager(manager)
, m_redirectCount(0)
{
m_reply = m_manager->get(QNetworkRequest(url));
connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished()));
}
void FollowRedirectReply::replyFinished()
{
int replyStatus = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if ((replyStatus != 301 && replyStatus != 302) || m_redirectCount == 5) {
emit finished();
return;
}
m_redirectCount++;
QUrl redirectUrl = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
m_reply->close();
m_reply->deleteLater();
m_reply = m_manager->get(QNetworkRequest(redirectUrl));
connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished()));
}
FollowRedirectReply::~FollowRedirectReply()
{
m_reply->close();
m_reply->deleteLater();
}