mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-15 14:39:50 +00:00
try once more
This commit is contained in:
@@ -10,25 +10,27 @@
|
|||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
class CurlManager{
|
class CurlManager {
|
||||||
public:
|
public:
|
||||||
CurlManager(){
|
CurlManager() {
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
}
|
}
|
||||||
~CurlManager(){
|
~CurlManager() {
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
}
|
}
|
||||||
inline CURL* Get(){
|
inline CURL* Get() {
|
||||||
return curl;
|
return curl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CURL *curl;
|
CURL* curl;
|
||||||
};
|
};
|
||||||
|
|
||||||
static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
|
static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
|
||||||
((std::string*)userp)->append((char*)contents, size * nmemb);
|
std::string((char*)userp).append((char*)contents, size * nmemb);
|
||||||
return size * nmemb;
|
return size * nmemb;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string HttpRequest(const std::string& IP, int port) {
|
std::string HttpRequest(const std::string& IP, int port) {
|
||||||
CurlManager M;
|
CurlManager M;
|
||||||
std::string readBuffer;
|
std::string readBuffer;
|
||||||
@@ -55,7 +57,7 @@ std::string PostHTTP(const std::string& IP, const std::string& Fields, bool json
|
|||||||
CURL* curl = M.Get();
|
CURL* curl = M.Get();
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
char readBuffer[5000];
|
char readBuffer[5000];
|
||||||
|
|
||||||
Assert(curl);
|
Assert(curl);
|
||||||
if (curl) {
|
if (curl) {
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, IP.c_str());
|
curl_easy_setopt(curl, CURLOPT_URL, IP.c_str());
|
||||||
|
|||||||
Reference in New Issue
Block a user