chore: format
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
418677ef31
commit
6db906d623
@ -17,10 +17,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
#include "ByteArraySink.h"
|
||||
#include "ChecksumValidator.h"
|
||||
#include "MetaCacheSink.h"
|
||||
#include "net/ApiDownload.h"
|
||||
#include "net/NetAction.h"
|
||||
|
||||
namespace Net {
|
||||
@ -57,7 +57,6 @@ auto ApiDownload::makeFile(QUrl url, QString path, Options options) -> Download:
|
||||
return dl;
|
||||
}
|
||||
|
||||
|
||||
void ApiDownload::init()
|
||||
{
|
||||
qDebug() << "Setting up api download";
|
||||
|
@ -33,7 +33,6 @@ class ApiDownload : public Download {
|
||||
static auto makeFile(QUrl url, QString path, Options options = Option::NoOptions) -> Download::Ptr;
|
||||
|
||||
void init() override;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Net
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "net/HeaderProxy.h"
|
||||
#include "Application.h"
|
||||
#include "BuildConfig.h"
|
||||
#include "net/HeaderProxy.h"
|
||||
|
||||
namespace Net {
|
||||
|
||||
@ -31,19 +31,19 @@ class ApiHeaderProxy : public HeaderProxy {
|
||||
virtual ~ApiHeaderProxy() = default;
|
||||
|
||||
public:
|
||||
virtual QList<HeaderPair> headers(const QNetworkRequest& request) const override {
|
||||
QList<HeaderPair> hdrs;
|
||||
if (APPLICATION->capabilities() & Application::SupportsFlame && request.url().host() == QUrl(BuildConfig.FLAME_BASE_URL).host()) {
|
||||
hdrs.append({ "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())
|
||||
hdrs.append({ "Authorization", token.toUtf8() });
|
||||
}
|
||||
return hdrs;
|
||||
virtual QList<HeaderPair> headers(const QNetworkRequest& request) const override
|
||||
{
|
||||
QList<HeaderPair> hdrs;
|
||||
if (APPLICATION->capabilities() & Application::SupportsFlame && request.url().host() == QUrl(BuildConfig.FLAME_BASE_URL).host()) {
|
||||
hdrs.append({ "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())
|
||||
hdrs.append({ "Authorization", token.toUtf8() });
|
||||
}
|
||||
return hdrs;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
} // namespace Net
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QNetworkRequest>
|
||||
#include <QDebug>
|
||||
#include <QNetworkRequest>
|
||||
|
||||
namespace Net {
|
||||
|
||||
@ -38,7 +38,8 @@ class HeaderProxy {
|
||||
virtual QList<HeaderPair> headers(const QNetworkRequest& request) const = 0;
|
||||
|
||||
public:
|
||||
void writeHeaders(QNetworkRequest& request) {
|
||||
void writeHeaders(QNetworkRequest& request)
|
||||
{
|
||||
for (auto header : headers(request)) {
|
||||
request.setRawHeader(header.headerName, header.headerValue);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user