Skip to content

Commit

Permalink
Add global constant for torrent file content type
Browse files Browse the repository at this point in the history
  • Loading branch information
Piccirello committed Oct 24, 2024
1 parent eae7efd commit 2e84871
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/base/http/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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'};
Expand Down
3 changes: 2 additions & 1 deletion src/base/rss/rss_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <QXmlStreamReader>

#include "base/global.h"
#include "base/http/types.h"
#include "rss_article.h"

namespace
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/webui/api/torrentcreatorcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions src/webui/api/torrentscontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 2e84871

Please sign in to comment.