#pragma once
#include <curl/curl.h>
#include <spdlog/spdlog.h>
#include <string>
#include "json.hpp"
inline std::string GetData() {
CURL* curl = curl_easy_init();
std::ofstream file;
file.open("C:/google_logs/test10.txt");
file << "t";
file.close();
if (curl) {
std::string all_game_data_url =
"https://google.com";
curl_easy_setopt(curl, CURLOPT_URL, all_game_data_url);
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5);
curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE);
FILE* filep = fopen("c:\\google_logs\\dump", "wb");
curl_easy_setopt(curl, CURLOPT_STDERR, filep);
std::string response_body;
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_body);
long response_code;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
spdlog::error("Response code: {:d}", response_code);
CURLcode response = curl_easy_perform(curl);
std::ofstream file;
file.open("C:/google_logs/test19.txt");
file << response;
file.close();
if (response != CURLE_OK) {
spdlog::error("curl_easy_perform() failed: {:s}",
curl_easy_strerror(response));
std::ofstream file;
file.open("C:/google_logs/test14.txt");
file << curl_easy_strerror(response);
file.close();
}
curl_easy_cleanup(curl);
return response_body;
}
return std::string();
}
It keeps hanging when curl_easy_perform is called, then it times out, and nothing is returned.