Mercurial > minori
view include/core/http.h @ 247:1ae4d8b28a5c
autotools/windres: use AC_PROG_SED for sed
sed is actually surprisingly unportable. on mingw this shouldn't
be a problem, but alas, we should use it anyway
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Wed, 24 Jan 2024 20:15:35 -0500 |
parents | 4d461ef7d424 |
children | 862d0d8619f6 |
line wrap: on
line source
#ifndef __core__http_h #define __core__http_h #include <QByteArray> #include <QThread> #include <string> #include <vector> namespace HTTP { QByteArray Get(const std::string& url, const std::vector<std::string>& headers = {}); QByteArray Post(const std::string& url, const std::string& data, const std::vector<std::string>& headers = {}); class GetThread : public QThread { Q_OBJECT public: GetThread(const std::string& u, const std::vector<std::string>& h = {}, QObject* parent = nullptr) : QThread(parent) { url = u; headers = h; } signals: void ReceivedData(const QByteArray& ba); protected: void run() override { emit ReceivedData(Get(url, headers)); } std::string url; std::vector<std::string> headers; }; class PostThread : public QThread { Q_OBJECT public: PostThread(const std::string& u, const std::string& d, const std::vector<std::string>& h = {}, QObject* parent = nullptr) : QThread(parent) { url = u; data = d; headers = h; } signals: void ReceivedData(const QByteArray& ba); protected: void run() override { emit ReceivedData(Post(url, data, headers)); } std::string url; std::string data; std::vector<std::string> headers; }; } // namespace HTTP #endif // __core__http_h