add Http::allow_redirects(bool allow_redirects) method

This commit is contained in:
2022-08-13 20:00:15 +02:00
parent ca1a854fd1
commit e88615226b
2 changed files with 17 additions and 1 deletions

View File

@@ -71,6 +71,7 @@ Http & Http::begin()
output_content_type = nullptr;
debug_mode = 0;
debug_info = nullptr;
follow_location = true;
return *this;
}
@@ -407,6 +408,12 @@ void Http::add_bearer_token()
}
void Http::allow_redirects(bool allow_redirects)
{
this->follow_location = allow_redirects;
}
void Http::initialize_curl_if_needed()
@@ -488,7 +495,7 @@ bool Http::fetch_internal(const char * url, const std::string * in, pt::TextStre
curl_easy_setopt(curl, CURLOPT_TIMEOUT, conn_timeout);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, conn_timeout);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buf);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, (follow_location) ? 1 : 0);
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 20);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);