aboutsummaryrefslogtreecommitdiff
path: root/launcher/net/HeaderProxy.h
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2023-08-04 20:31:43 +0200
committerGitHub <noreply@github.com>2023-08-04 20:31:43 +0200
commit304e294ea701e595b21c0a8a8236ca53828f2b3b (patch)
tree66770810d344120899cf8ba07f279bac784f4877 /launcher/net/HeaderProxy.h
parent50c7d39e082f0a7dbd977401e16d5adf534d9770 (diff)
parentf19e8dd086cd046c694a4a9a02d83827b08952b0 (diff)
downloadPrismLauncher-304e294ea701e595b21c0a8a8236ca53828f2b3b.tar.gz
PrismLauncher-304e294ea701e595b21c0a8a8236ca53828f2b3b.tar.bz2
PrismLauncher-304e294ea701e595b21c0a8a8236ca53828f2b3b.zip
Merge pull request #1102 from Ryex/refactor/net-split-headers-to-proxy-class
Diffstat (limited to 'launcher/net/HeaderProxy.h')
-rw-r--r--launcher/net/HeaderProxy.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/launcher/net/HeaderProxy.h b/launcher/net/HeaderProxy.h
new file mode 100644
index 00000000..f41c5875
--- /dev/null
+++ b/launcher/net/HeaderProxy.h
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+#pragma once
+
+#include <QDebug>
+#include <QNetworkRequest>
+
+namespace Net {
+
+struct HeaderPair {
+ QByteArray headerName;
+ QByteArray headerValue;
+};
+
+class HeaderProxy {
+ public:
+ HeaderProxy(){};
+ virtual ~HeaderProxy(){};
+
+ public:
+ virtual QList<HeaderPair> headers(const QNetworkRequest& request) const = 0;
+
+ public:
+ void writeHeaders(QNetworkRequest& request)
+ {
+ for (auto header : headers(request)) {
+ request.setRawHeader(header.headerName, header.headerValue);
+ }
+ }
+};
+
+} // namespace Net