Mercurial > minori
comparison include/core/http.h @ 77:6f7385bd334c
*: update
formatted all source files, no more subclassing QThread... many other
changes :)
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Fri, 06 Oct 2023 06:18:53 -0400 |
| parents | 3364fadc8a36 |
| children | f5940a575d83 |
comparison
equal
deleted
inserted
replaced
| 76:3364fadc8a36 | 77:6f7385bd334c |
|---|---|
| 1 #ifndef __core__http_h | 1 #ifndef __core__http_h |
| 2 #define __core__http_h | 2 #define __core__http_h |
| 3 | 3 |
| 4 #include <QThread> | 4 #include <QByteArray> |
| 5 #include <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 class QObject; | |
| 9 | |
| 10 namespace HTTP { | 8 namespace HTTP { |
| 11 | 9 |
| 12 class HttpGetThread : public QThread { | 10 QByteArray Get(std::string url, std::vector<std::string> headers = {}); |
| 13 Q_OBJECT | 11 QByteArray Post(std::string url, std::string data, std::vector<std::string> headers = {}); |
| 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 | 12 |
| 31 } // namespace HTTP | 13 } // namespace HTTP |
| 32 | 14 |
| 33 #endif // __core__http_h | 15 #endif // __core__http_h |
