From 275afb730fa762f09836f3b38b2e25ff0128faa0 Mon Sep 17 00:00:00 2001 From: Silarn Date: Mon, 30 Apr 2018 13:56:27 -0500 Subject: A couple download header-based fixes * If an unknown content error, only fail if the filesize is off * If a text content type, output a warning but do not retry the download --- src/downloadmanager.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/downloadmanager.cpp') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index aec2ad85..77a4cf98 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1431,15 +1431,16 @@ void DownloadManager::downloadFinished() if ((info->m_State != STATE_CANCELING) && (info->m_State != STATE_PAUSING)) { bool textData = reply->header(QNetworkRequest::ContentTypeHeader).toString().startsWith("text", Qt::CaseInsensitive); + if (textData) + emit showMessage(tr("Warning: Content type is: %1").arg(reply->header(QNetworkRequest::ContentTypeHeader).toString())); if ((info->m_Output.size() == 0) || - ((reply->error() != QNetworkReply::NoError) && (reply->error() != QNetworkReply::OperationCanceledError)) || - textData) { + ((reply->error() != QNetworkReply::NoError) + && (reply->error() != QNetworkReply::OperationCanceledError) + && (reply->error() == QNetworkReply::UnknownContentError && (info->m_Output.size() != reply->header(QNetworkRequest::ContentLengthHeader).toLongLong())))) { + if (reply->error() == QNetworkReply::UnknownContentError) + emit showMessage(tr("Download header content length: %1 downloaded file size: %2").arg(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong()).arg(info->m_Output.size())); if (info->m_Tries == 0) { - if (textData && (reply->error() == QNetworkReply::NoError)) { - emit showMessage(tr("Download failed. Server reported: %1").arg(QString(data))); - } else { - emit showMessage(tr("Download failed: %1 (%2)").arg(reply->errorString()).arg(reply->error())); - } + emit showMessage(tr("Download failed: %1 (%2)").arg(reply->errorString()).arg(reply->error())); } error = true; setState(info, STATE_PAUSING); -- cgit v1.3.1