comparison 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
comparison
equal deleted inserted replaced
74:5ccb99bfa605 75:d3e9310598b1
1 #ifndef __core__http_h
2 #define __core__http_h
3
4 #include <string>
5 #include <vector>
6 #include <QThread>
7
8 class QObject;
9
10 namespace HTTP {
11
12 class HttpGetThread : public QThread {
13 Q_OBJECT
14
15 public:
16 HttpGetThread(std::string url, std::vector<std::string> headers = {}, QObject* parent = nullptr);
17
18 private:
19 static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userdata);
20 void run() override;
21 std::string _url;
22 std::vector<std::string> _headers;
23
24 signals:
25 void resultReady(const QByteArray& arr);
26 };
27
28 /* Performs a basic (blocking) post request */
29 std::string PerformBasicPostRequest(std::string url, std::string data, std::vector<std::string> headers = {});
30
31 }
32
33 #endif // __core__http_h