diff include/core/http.h @ 75:d3e9310598b1

*: refactor some stuff text: "TextParagraph"s are now called sections, because that's the actual word for it :P text: new classes: Line and OneLineSection, solves many problems with paragraphs that are only one line long (ex. going out of bounds) http: reworked http stuff to allow threaded get requests, also moved it to its own file to (hopefully) remove clutter eventually I'll make a threaded post request method and use that in the "basic" function
author Paper <mrpapersonic@gmail.com>
date Wed, 04 Oct 2023 01:42:30 -0400
parents
children 3364fadc8a36
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/core/http.h	Wed Oct 04 01:42:30 2023 -0400
@@ -0,0 +1,33 @@
+#ifndef __core__http_h
+#define __core__http_h
+
+#include <string>
+#include <vector>
+#include <QThread>
+
+class QObject;
+
+namespace HTTP {
+
+class HttpGetThread : public QThread {
+		Q_OBJECT
+
+	public:
+		HttpGetThread(std::string url, std::vector<std::string> headers = {}, QObject* parent = nullptr);
+
+	private:
+		static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userdata);
+		void run() override;
+		std::string _url;
+		std::vector<std::string> _headers;
+
+	signals:
+		void resultReady(const QByteArray& arr);
+};
+
+/* Performs a basic (blocking) post request */
+std::string PerformBasicPostRequest(std::string url, std::string data, std::vector<std::string> headers = {});
+
+}
+
+#endif // __core__http_h