mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-01 23:46:59 +00:00
27 lines
804 B
C++
27 lines
804 B
C++
///
|
|
/// Created by Anonymous275 on 3/17/2020
|
|
///
|
|
|
|
#define CURL_STATICLIB
|
|
#include "curl/curl.h"
|
|
#include <iostream>
|
|
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
|
|
{
|
|
((std::string*)userp)->append((char*)contents, size * nmemb);
|
|
return size * nmemb;
|
|
}
|
|
std::string HTTP_REQUEST(const std::string& IP,int port){
|
|
CURL *curl;
|
|
CURLcode res;
|
|
std::string readBuffer;
|
|
curl = curl_easy_init();
|
|
if(curl) {
|
|
curl_easy_setopt(curl, CURLOPT_URL, IP.c_str());
|
|
curl_easy_setopt(curl, CURLOPT_PORT, port);
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
|
|
res = curl_easy_perform(curl);
|
|
curl_easy_cleanup(curl);
|
|
}
|
|
return readBuffer;
|
|
} |