From 46598a85fce13c30785fb8270051e6bfeaf5908f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Tue, 17 Jan 2017 10:37:02 +0100 Subject: [PATCH] Fixed redirect loop handling logic --- src/downloader.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/downloader.cpp b/src/downloader.cpp index 38b6ef7b..1f4de54c 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -95,12 +95,17 @@ void Downloader::downloadFinished(QNetworkReply *reply) QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl(); int level = reply->request().attribute(ATTR_LEVEL).toInt(); - if (level >= MAX_REDIRECT_LEVEL) + if (location == url) { + _errorDownloads.insert(url); + fprintf(stderr, "Error downloading map tile: %s: " + "redirect loop\n", url.toEncoded().constData()); + } else if (level >= MAX_REDIRECT_LEVEL) { + _errorDownloads.insert(origin); fprintf(stderr, "Error downloading map tile: %s: " "redirect level limit reached\n", origin.toEncoded().constData()); - else { - Redirect redirect(origin.isEmpty() ? url : origin, level++); + } else { + Redirect redirect(origin.isEmpty() ? url : origin, level + 1); Download dl(location, filename); doDownload(dl, redirect); }