2023-08-21 14:22:41 +08:00
|
|
|
#ifndef __REQUEST_H__
|
|
|
|
|
#define __REQUEST_H__
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
|
|
#include "Response.h"
|
|
|
|
|
namespace Req {
|
|
|
|
|
class Request {
|
|
|
|
|
public:
|
|
|
|
|
static void Init();
|
|
|
|
|
static void Dispose();
|
|
|
|
|
Request();
|
|
|
|
|
Request(Request &&) = delete;
|
|
|
|
|
Request(const Request &) = delete;
|
|
|
|
|
Request &operator=(Request &&) = delete;
|
|
|
|
|
Request &operator=(const Request &) = delete;
|
|
|
|
|
~Request();
|
2023-08-22 10:47:19 +08:00
|
|
|
bool isValid();
|
2023-08-21 14:22:41 +08:00
|
|
|
void setClientCertificate(const std::string &cerPath, const std::string &keyPath);
|
|
|
|
|
void setVerbose(bool verbose);
|
2023-08-22 10:47:19 +08:00
|
|
|
Response* post(const std::string& url, const std::string &body = std::string(),
|
2023-08-21 14:22:41 +08:00
|
|
|
const std::unordered_map<std::string, std::string>& headers =
|
|
|
|
|
std::unordered_map<std::string, std::string>());
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void* mCurl;
|
|
|
|
|
void* mHeaders;
|
|
|
|
|
std::string mCert;
|
|
|
|
|
std::string mKey;
|
|
|
|
|
bool mVerbose;
|
2023-08-22 10:47:19 +08:00
|
|
|
bool mValid;
|
|
|
|
|
|
2023-08-21 14:22:41 +08:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
#endif // __REQUEST_H__
|