mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-03 11:54:27 +00:00
Common/HttpRequest: optionally follow redirects
This commit is contained in:
parent
a129d60a57
commit
3ff0e7dbd4
@ -30,6 +30,7 @@ public:
|
|||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
void SetCookies(const std::string& cookies);
|
void SetCookies(const std::string& cookies);
|
||||||
void UseIPv4();
|
void UseIPv4();
|
||||||
|
void FollowRedirects(long max);
|
||||||
Response Fetch(const std::string& url, Method method, const Headers& headers, const u8* payload,
|
Response Fetch(const std::string& url, Method method, const Headers& headers, const u8* payload,
|
||||||
size_t size);
|
size_t size);
|
||||||
|
|
||||||
@ -68,6 +69,11 @@ void HttpRequest::UseIPv4()
|
|||||||
m_impl->UseIPv4();
|
m_impl->UseIPv4();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HttpRequest::FollowRedirects(long max)
|
||||||
|
{
|
||||||
|
m_impl->FollowRedirects(max);
|
||||||
|
}
|
||||||
|
|
||||||
HttpRequest::Response HttpRequest::Get(const std::string& url, const Headers& headers)
|
HttpRequest::Response HttpRequest::Get(const std::string& url, const Headers& headers)
|
||||||
{
|
{
|
||||||
return m_impl->Fetch(url, Impl::Method::GET, headers, nullptr, 0);
|
return m_impl->Fetch(url, Impl::Method::GET, headers, nullptr, 0);
|
||||||
@ -147,6 +153,12 @@ void HttpRequest::Impl::UseIPv4()
|
|||||||
curl_easy_setopt(m_curl.get(), CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
curl_easy_setopt(m_curl.get(), CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HttpRequest::Impl::FollowRedirects(long max)
|
||||||
|
{
|
||||||
|
curl_easy_setopt(m_curl.get(), CURLOPT_FOLLOWLOCATION, 1);
|
||||||
|
curl_easy_setopt(m_curl.get(), CURLOPT_MAXREDIRS, max);
|
||||||
|
}
|
||||||
|
|
||||||
static size_t CurlWriteCallback(char* data, size_t size, size_t nmemb, void* userdata)
|
static size_t CurlWriteCallback(char* data, size_t size, size_t nmemb, void* userdata)
|
||||||
{
|
{
|
||||||
auto* buffer = static_cast<std::vector<u8>*>(userdata);
|
auto* buffer = static_cast<std::vector<u8>*>(userdata);
|
||||||
|
@ -33,6 +33,7 @@ public:
|
|||||||
|
|
||||||
void SetCookies(const std::string& cookies);
|
void SetCookies(const std::string& cookies);
|
||||||
void UseIPv4();
|
void UseIPv4();
|
||||||
|
void FollowRedirects(long max = 1);
|
||||||
Response Get(const std::string& url, const Headers& headers = {});
|
Response Get(const std::string& url, const Headers& headers = {});
|
||||||
Response Post(const std::string& url, const std::vector<u8>& payload,
|
Response Post(const std::string& url, const std::vector<u8>& payload,
|
||||||
const Headers& headers = {});
|
const Headers& headers = {});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user