Skip to content

Commit

Permalink
follow HTTP redirects (#133)
Browse files Browse the repository at this point in the history
Follow HTTP redirects on HTTP Get and Post functions
  • Loading branch information
lionkor authored Oct 6, 2024
2 parents fcb51ad + ace96b7 commit f57ebb7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Network/Http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ std::string HTTP::Get(const std::string& IP) {
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&Ret);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10); // seconds
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
error("GET to " + IP + " failed: " + std::string(curl_easy_strerror(res)));
Expand Down Expand Up @@ -105,6 +106,7 @@ std::string HTTP::Post(const std::string& IP, const std::string& Fields) {
list = curl_slist_append(list, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10); // seconds
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
res = curl_easy_perform(curl);
curl_slist_free_all(list);
if (res != CURLE_OK) {
Expand Down

0 comments on commit f57ebb7

Please sign in to comment.