view include/core/http.h @ 76:3364fadc8a36

*: format source code
author Paper <mrpapersonic@gmail.com>
date Wed, 04 Oct 2023 01:46:33 -0400
parents d3e9310598b1
children 6f7385bd334c
line wrap: on
line source

#ifndef __core__http_h
#define __core__http_h

#include <QThread>
#include <string>
#include <vector>

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 = {});

} // namespace HTTP

#endif // __core__http_h