diff --git a/src/base/http/types.h b/src/base/http/types.h index 8641003e84a..9f553dde546 100644 --- a/src/base/http/types.h +++ b/src/base/http/types.h @@ -74,6 +74,7 @@ namespace Http inline const QString CONTENT_TYPE_PNG = u"image/png"_s; inline const QString CONTENT_TYPE_FORM_ENCODED = u"application/x-www-form-urlencoded"_s; inline const QString CONTENT_TYPE_FORM_DATA = u"multipart/form-data"_s; + inline const QString CONTENT_TYPE_TORRENT_FILE = u"application/x-bittorrent"_s; // portability: "\r\n" doesn't guarantee mapping to the correct symbol inline const char CRLF[] = {0x0D, 0x0A, '\0'}; diff --git a/src/base/rss/rss_parser.cpp b/src/base/rss/rss_parser.cpp index 07fa7dffdd1..bc036703c4a 100644 --- a/src/base/rss/rss_parser.cpp +++ b/src/base/rss/rss_parser.cpp @@ -42,6 +42,7 @@ #include #include "base/global.h" +#include "base/http/types.h" #include "rss_article.h" namespace @@ -623,7 +624,7 @@ void RSS::Private::Parser::parseRssArticle(QXmlStreamReader &xml) } else if (name == u"enclosure") { - if (xml.attributes().value(u"type"_s) == u"application/x-bittorrent") + if (xml.attributes().value(u"type"_s) == Http::CONTENT_TYPE_TORRENT_FILE) article[Article::KeyTorrentURL] = xml.attributes().value(u"url"_s).toString(); else if (xml.attributes().value(u"type"_s).isEmpty()) altTorrentUrl = xml.attributes().value(u"url"_s).toString(); diff --git a/src/webui/api/torrentcreatorcontroller.cpp b/src/webui/api/torrentcreatorcontroller.cpp index ced5ec390c4..b6ee20ef010 100644 --- a/src/webui/api/torrentcreatorcontroller.cpp +++ b/src/webui/api/torrentcreatorcontroller.cpp @@ -35,6 +35,7 @@ #include "base/global.h" #include "base/bittorrent/torrentcreationmanager.h" +#include "base/http/types.h" #include "base/preferences.h" #include "base/utils/io.h" #include "base/utils/string.h" @@ -234,7 +235,7 @@ void TorrentCreatorController::torrentFileAction() if (!readResult) throw APIError(APIErrorType::Conflict, readResult.error().message); - setResult(readResult.value(), u"application/x-bittorrent"_s, (id + u".torrent")); + setResult(readResult.value(), Http::CONTENT_TYPE_TORRENT_FILE, (id + u".torrent")); } void TorrentCreatorController::deleteTaskAction() diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index 0c11b03bda9..733761c4ab3 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -52,6 +52,7 @@ #include "base/bittorrent/trackerentrystatus.h" #include "base/interfaces/iapplication.h" #include "base/global.h" +#include "base/http/types.h" #include "base/logger.h" #include "base/preferences.h" #include "base/torrentfilter.h" @@ -1749,7 +1750,7 @@ void TorrentsController::exportAction() if (!result) throw APIError(APIErrorType::Conflict, tr("Unable to export torrent file. Error: %1").arg(result.error())); - setResult(result.value(), u"application/x-bittorrent"_s, (id.toString() + u".torrent")); + setResult(result.value(), Http::CONTENT_TYPE_TORRENT_FILE, (id.toString() + u".torrent")); } void TorrentsController::SSLParametersAction() @@ -1945,7 +1946,7 @@ void TorrentsController::saveMetadataAction() if (!result) throw APIError(APIErrorType::Conflict, tr("Unable to export torrent metadata. Error: %1").arg(result.error())); - setResult(result.value(), u"application/x-bittorrent"_s, (infoHash.toTorrentID().toString() + u".torrent")); + setResult(result.value(), Http::CONTENT_TYPE_TORRENT_FILE, (infoHash.toTorrentID().toString() + u".torrent")); return; }