Lucas-Bot/dependencies/Http/http.h

65 lines
1.8 KiB
C
Raw Normal View History

2022-10-08 22:47:18 +08:00
/*
* This file is part of Lucas' Bot.
*
* Lucas' Bot is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
Lucas' Bot is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
for more details.
You should have received a copy of the GNU Affero General Public License along
with Lucas' Bot. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef HTTP_LIBRARY_H
#define HTTP_LIBRARY_H
2022-10-20 13:15:42 +08:00
#ifdef _MSC_VER
#ifdef EXPORT_HTTP
#define HTTP_LIB __declspec(dllexport)
#else
#define HTTP_LIB __declspec(dllimport)
#endif
2022-10-20 16:14:46 +08:00
#else
#define HTTP_LIB
2022-10-20 13:15:42 +08:00
#endif
2022-10-08 22:47:18 +08:00
#include <string>
namespace Http {
2022-10-20 13:15:42 +08:00
class HTTP_LIB Request {
2022-10-08 22:47:18 +08:00
public:
Request();
~Request();
void setUrl(const std::string&);
void setMethod(const std::string&);
void setBody(const std::string&);
void setHeader(const std::string&);
void setVerbose(bool verbose);
std::string getResponse();
void send();
private:
std::string url;
std::string method;
std::string body;
std::string header;
std::string response;
bool verbose;
static size_t writeCallback(char *ptr, size_t size, size_t nmemb, void *userdata);
};
2022-10-20 13:15:42 +08:00
class HTTP_LIB FileUtilities {
2022-10-08 22:47:18 +08:00
public:
static std::string readFile(const std::string& path);
static void writeFile(const std::string& path, const std::string& content);
};
}
2022-10-20 13:15:42 +08:00
2022-10-08 22:47:18 +08:00
#endif //HTTP_LIBRARY_H
2022-10-20 13:15:42 +08:00