1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Fixed redirect loop handling logic

This commit is contained in:
Martin Tůma 2017-01-17 10:37:02 +01:00
parent 32cbd33c91
commit 46598a85fc

View File

@ -95,12 +95,17 @@ void Downloader::downloadFinished(QNetworkReply *reply)
QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl(); QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl();
int level = reply->request().attribute(ATTR_LEVEL).toInt(); 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: " fprintf(stderr, "Error downloading map tile: %s: "
"redirect level limit reached\n", "redirect level limit reached\n",
origin.toEncoded().constData()); origin.toEncoded().constData());
else { } else {
Redirect redirect(origin.isEmpty() ? url : origin, level++); Redirect redirect(origin.isEmpty() ? url : origin, level + 1);
Download dl(location, filename); Download dl(location, filename);
doDownload(dl, redirect); doDownload(dl, redirect);
} }