mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-22 06:43:54 -07:00
detect recursive redirects (#6570)
* detect recursive redirects * handle failure with normal failure handler
This commit is contained in:
parent
c02cf5e89e
commit
303bd8b607
1 changed files with 8 additions and 2 deletions
|
|
@ -70,16 +70,22 @@ void CardPictureLoaderWorkerWork::picDownloadFailed()
|
||||||
void CardPictureLoaderWorkerWork::handleNetworkReply(QNetworkReply *reply)
|
void CardPictureLoaderWorkerWork::handleNetworkReply(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
QVariant redirectTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
|
QVariant redirectTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
|
||||||
|
bool redirectFailure = false;
|
||||||
if (redirectTarget.isValid()) {
|
if (redirectTarget.isValid()) {
|
||||||
QUrl url = reply->request().url();
|
QUrl url = reply->request().url();
|
||||||
QUrl redirectUrl = redirectTarget.toUrl();
|
QUrl redirectUrl = redirectTarget.toUrl();
|
||||||
if (redirectUrl.isRelative()) {
|
if (redirectUrl.isRelative()) {
|
||||||
redirectUrl = url.resolved(redirectUrl);
|
redirectUrl = url.resolved(redirectUrl);
|
||||||
}
|
}
|
||||||
emit urlRedirected(url, redirectUrl);
|
if (url == redirectUrl) {
|
||||||
|
qCWarning(CardPictureLoaderWorkerWorkLog) << "recusive redirect detected!";
|
||||||
|
redirectFailure = true;
|
||||||
|
} else {
|
||||||
|
emit urlRedirected(url, redirectUrl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reply->error()) {
|
if (redirectFailure || reply->error()) {
|
||||||
handleFailedReply(reply);
|
handleFailedReply(reply);
|
||||||
} else {
|
} else {
|
||||||
handleSuccessfulReply(reply);
|
handleSuccessfulReply(reply);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue