Skip to content
Permalink
Browse files

Common/HttpRequest: Implement EscapeComponent

  • Loading branch information...
spycrab committed Mar 30, 2019
1 parent 0bce1c5 commit 3dbf44417a7cc50e7e173bd710a5fcb904bdfe20
Showing with 12 additions and 0 deletions.
  1. +11 −0 Source/Core/Common/HttpRequest.cpp
  2. +1 −0 Source/Core/Common/HttpRequest.h
@@ -36,6 +36,7 @@ class HttpRequest::Impl final

static int CurlProgressCallback(Impl* impl, double dlnow, double dltotal, double ulnow,
double ultotal);
const std::string EscapeComponent(const std::string& string);

private:
static std::mutex s_curl_was_inited_mutex;
@@ -74,6 +75,11 @@ void HttpRequest::FollowRedirects(long max)
m_impl->FollowRedirects(max);
}

const std::string HttpRequest::EscapeComponent(const std::string& string)
{
return m_impl->EscapeComponent(string);
}

HttpRequest::Response HttpRequest::Get(const std::string& url, const Headers& headers)
{
return m_impl->Fetch(url, Impl::Method::GET, headers, nullptr, 0);
@@ -159,6 +165,11 @@ void HttpRequest::Impl::FollowRedirects(long max)
curl_easy_setopt(m_curl.get(), CURLOPT_MAXREDIRS, max);
}

const std::string HttpRequest::Impl::EscapeComponent(const std::string& string)
{
return curl_easy_escape(m_curl.get(), string.c_str(), static_cast<int>(string.size()));
}

static size_t CurlWriteCallback(char* data, size_t size, size_t nmemb, void* userdata)
{
auto* buffer = static_cast<std::vector<u8>*>(userdata);
@@ -34,6 +34,7 @@ class HttpRequest final
void SetCookies(const std::string& cookies);
void UseIPv4();
void FollowRedirects(long max = 1);
const std::string EscapeComponent(const std::string& string);
Response Get(const std::string& url, const Headers& headers = {});
Response Post(const std::string& url, const std::vector<u8>& payload,
const Headers& headers = {});

0 comments on commit 3dbf444

Please sign in to comment.
You can’t perform that action at this time.