diff include/core/http.h @ 301:b1f625b0227c

*: convert all files CRLF -> LF some files were in DOS format, others were in unix. now everything (that at least is under our control) should all be the same format
author Paper <paper@paper.us.eu.org>
date Mon, 13 May 2024 15:04:51 -0400
parents 9a88e1725fd2
children b1f4d1867ab1
line wrap: on
line diff
--- a/include/core/http.h	Mon May 13 14:56:37 2024 -0400
+++ b/include/core/http.h	Mon May 13 15:04:51 2024 -0400
@@ -1,58 +1,58 @@
-#ifndef MINORI_CORE_HTTP_H_
-#define MINORI_CORE_HTTP_H_
-
-#include <QByteArray>
-#include <QThread>
-
-#include <string>
-#include <vector>
-#include <mutex>
-
-namespace HTTP {
-
-enum class Type {
-	Get,
-	Post
-};
-
-QByteArray Request(const std::string& url, const std::vector<std::string>& headers = {}, const std::string& data = "", Type type = Type::Get);
-
-class RequestThread final : public QThread {
-	Q_OBJECT
-
-public:
-	RequestThread(Type type = Type::Get, QObject* parent = nullptr);
-	RequestThread(const std::string& url, const std::vector<std::string>& headers = {},
-		          const std::string& data = "", Type type = Type::Get, QObject* parent = nullptr);
-	~RequestThread();
-
-	void SetUrl(const std::string& url);
-	void SetHeaders(const std::vector<std::string>& headers);
-	void SetData(const std::string& data);
-	void SetType(Type type);
-
-	void Stop();
-
-signals:
-	void ReceivedData(const QByteArray& ba);
-
-protected:
-	void run() override;
-	static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userdata);
-
-	std::string url_;
-	std::string data_;
-	std::vector<std::string> headers_;
-	Type type_;
-
-	/* these are passed to the write callback */
-	QByteArray array_;
-	bool cancelled_ = false;
-
-	/* don't fuck this up */
-	std::mutex callback_data_mutex_;
-};
-
-} // namespace HTTP
-
-#endif // MINORI_CORE_HTTP_H_
+#ifndef MINORI_CORE_HTTP_H_
+#define MINORI_CORE_HTTP_H_
+
+#include <QByteArray>
+#include <QThread>
+
+#include <string>
+#include <vector>
+#include <mutex>
+
+namespace HTTP {
+
+enum class Type {
+	Get,
+	Post
+};
+
+QByteArray Request(const std::string& url, const std::vector<std::string>& headers = {}, const std::string& data = "", Type type = Type::Get);
+
+class RequestThread final : public QThread {
+	Q_OBJECT
+
+public:
+	RequestThread(Type type = Type::Get, QObject* parent = nullptr);
+	RequestThread(const std::string& url, const std::vector<std::string>& headers = {},
+		          const std::string& data = "", Type type = Type::Get, QObject* parent = nullptr);
+	~RequestThread();
+
+	void SetUrl(const std::string& url);
+	void SetHeaders(const std::vector<std::string>& headers);
+	void SetData(const std::string& data);
+	void SetType(Type type);
+
+	void Stop();
+
+signals:
+	void ReceivedData(const QByteArray& ba);
+
+protected:
+	void run() override;
+	static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userdata);
+
+	std::string url_;
+	std::string data_;
+	std::vector<std::string> headers_;
+	Type type_;
+
+	/* these are passed to the write callback */
+	QByteArray array_;
+	bool cancelled_ = false;
+
+	/* don't fuck this up */
+	std::mutex callback_data_mutex_;
+};
+
+} // namespace HTTP
+
+#endif // MINORI_CORE_HTTP_H_