mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-01-25 19:04:48 -08:00
detect recursive redirects (#6570)
* detect recursive redirects * handle failure with normal failure handler
This commit is contained in:
@@ -70,16 +70,22 @@ void CardPictureLoaderWorkerWork::picDownloadFailed()
|
||||
void CardPictureLoaderWorkerWork::handleNetworkReply(QNetworkReply *reply)
|
||||
{
|
||||
QVariant redirectTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
|
||||
bool redirectFailure = false;
|
||||
if (redirectTarget.isValid()) {
|
||||
QUrl url = reply->request().url();
|
||||
QUrl redirectUrl = redirectTarget.toUrl();
|
||||
if (redirectUrl.isRelative()) {
|
||||
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);
|
||||
} else {
|
||||
handleSuccessfulReply(reply);
|
||||
|
||||
Reference in New Issue
Block a user