diff options
| author | Silarn <jrim@rimpo.org> | 2018-04-30 13:56:27 -0500 |
|---|---|---|
| committer | Silarn <jrim@rimpo.org> | 2018-04-30 13:56:27 -0500 |
| commit | 275afb730fa762f09836f3b38b2e25ff0128faa0 (patch) | |
| tree | bbfae7a900f875cf068c773fd18641cc08070f56 /src/downloadmanager.cpp | |
| parent | 0306b0fc42ba1dbd76d86466ed045eab4e45186d (diff) | |
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
Diffstat (limited to 'src/downloadmanager.cpp')
| -rw-r--r-- | src/downloadmanager.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
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);
|
