refactor: split out setting api headers for downloads
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
af6bf11793
commit
9c10965997
38 changed files with 303 additions and 68 deletions
|
@ -124,15 +124,11 @@ void Download::executeTask()
|
|||
}
|
||||
|
||||
request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8());
|
||||
// TODO remove duplication
|
||||
if (APPLICATION->capabilities() & Application::SupportsFlame && request.url().host() == QUrl(BuildConfig.FLAME_BASE_URL).host()) {
|
||||
request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8());
|
||||
} else if (request.url().host() == QUrl(BuildConfig.MODRINTH_PROD_URL).host() ||
|
||||
request.url().host() == QUrl(BuildConfig.MODRINTH_STAGING_URL).host()) {
|
||||
QString token = APPLICATION->getModrinthAPIToken();
|
||||
if (!token.isNull())
|
||||
request.setRawHeader("Authorization", token.toUtf8());
|
||||
for ( auto header_proxy : m_headerProxies ) {
|
||||
header_proxy->writeHeaders(request);
|
||||
}
|
||||
// TODO remove duplication
|
||||
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
request.setTransferTimeout();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue