diff options
Diffstat (limited to 'src/downloadmanager.cpp')
-rw-r--r-- | src/downloadmanager.cpp | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 6241394a..2e7e4607 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -201,43 +201,3 @@ bool DownloadManager::downloadResource(const KUrl &srcUrl, const KIO::MetaData & job->uiDelegate()->setAutoErrorHandlingEnabled(true); return true; } - - -// ------------------------------------------------------------------------------------------------------------------- - - -// STATIC -void DownloadManager::extractSuggestedFileName(const QNetworkReply* reply, QString& fileName) -{ - fileName.clear(); - const KIO::MetaData& metaData = reply->attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)).toMap(); - if (metaData.value(QL1S("content-disposition-type")).compare(QL1S("attachment"), Qt::CaseInsensitive) == 0) - fileName = metaData.value(QL1S("content-disposition-filename")); - - if (!fileName.isEmpty()) - return; - - if (!reply->hasRawHeader("Content-Disposition")) - return; - - const QString value(QL1S(reply->rawHeader("Content-Disposition").simplified().constData())); - if (value.startsWith(QL1S("attachment"), Qt::CaseInsensitive) || value.startsWith(QL1S("inline"), Qt::CaseInsensitive)) - { - const int length = value.size(); - int pos = value.indexOf(QL1S("filename"), 0, Qt::CaseInsensitive); - if (pos > -1) - { - pos += 9; - while (pos < length && (value.at(pos) == QL1C(' ') || value.at(pos) == QL1C('=') || value.at(pos) == QL1C('"'))) - pos++; - - int endPos = pos; - while (endPos < length && value.at(endPos) != QL1C('"') && value.at(endPos) != QL1C(';')) - endPos++; - - if (endPos > pos) - fileName = value.mid(pos, (endPos - pos)).trimmed(); - } - } -} - |