diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2022-08-17 01:42:30 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2022-08-17 01:42:30 -0400 |
commit | 32fc7def7c5936e9a4c8c4d9b36b9a7570ca8664 (patch) | |
tree | 5803088f63b91967ca28a64eb53b0b701c43e35d /src/discord/httpclient.cpp | |
parent | 14602a73842f0c57eda857503a3539a9d9aa4089 (diff) | |
download | abaddon-portaudio-32fc7def7c5936e9a4c8c4d9b36b9a7570ca8664.tar.gz abaddon-portaudio-32fc7def7c5936e9a4c8c4d9b36b9a7570ca8664.zip |
fetch cookies and build number on startup
Diffstat (limited to 'src/discord/httpclient.cpp')
-rw-r--r-- | src/discord/httpclient.cpp | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/src/discord/httpclient.cpp b/src/discord/httpclient.cpp index d13246d..cc0bb93 100644 --- a/src/discord/httpclient.cpp +++ b/src/discord/httpclient.cpp @@ -2,7 +2,6 @@ #include <utility> -//#define USE_LOCAL_PROXY HTTPClient::HTTPClient() { m_dispatcher.connect(sigc::mem_fun(*this, &HTTPClient::RunCallbacks)); } @@ -23,6 +22,10 @@ void HTTPClient::SetPersistentHeader(std::string name, std::string value) { m_headers.insert_or_assign(std::move(name), std::move(value)); } +void HTTPClient::SetCookie(std::string_view cookie) { + m_cookie = cookie; +} + void HTTPClient::MakeDELETE(const std::string &path, const std::function<void(http::response_type r)> &cb) { printf("DELETE %s\n", path.c_str()); m_futures.push_back(std::async(std::launch::async, [this, path, cb] { @@ -31,10 +34,6 @@ void HTTPClient::MakeDELETE(const std::string &path, const std::function<void(ht req.set_header("Authorization", m_authorization); req.set_header("Origin", "https://discord.com"); req.set_user_agent(!m_agent.empty() ? m_agent : "Abaddon"); -#ifdef USE_LOCAL_PROXY - req.set_proxy("http://127.0.0.1:8888"); - req.set_verify_ssl(false); -#endif auto res = req.execute(); @@ -52,10 +51,6 @@ void HTTPClient::MakePATCH(const std::string &path, const std::string &payload, req.set_header("Origin", "https://discord.com"); req.set_user_agent(!m_agent.empty() ? m_agent : "Abaddon"); req.set_body(payload); -#ifdef USE_LOCAL_PROXY - req.set_proxy("http://127.0.0.1:8888"); - req.set_verify_ssl(false); -#endif auto res = req.execute(); @@ -73,10 +68,6 @@ void HTTPClient::MakePOST(const std::string &path, const std::string &payload, c req.set_header("Origin", "https://discord.com"); req.set_user_agent(!m_agent.empty() ? m_agent : "Abaddon"); req.set_body(payload); -#ifdef USE_LOCAL_PROXY - req.set_proxy("http://127.0.0.1:8888"); - req.set_verify_ssl(false); -#endif auto res = req.execute(); @@ -95,10 +86,6 @@ void HTTPClient::MakePUT(const std::string &path, const std::string &payload, co req.set_header("Content-Type", "application/json"); req.set_user_agent(!m_agent.empty() ? m_agent : "Abaddon"); req.set_body(payload); -#ifdef USE_LOCAL_PROXY - req.set_proxy("http://127.0.0.1:8888"); - req.set_verify_ssl(false); -#endif auto res = req.execute(); @@ -113,10 +100,6 @@ void HTTPClient::MakeGET(const std::string &path, const std::function<void(http: AddHeaders(req); req.set_header("Authorization", m_authorization); req.set_user_agent(!m_agent.empty() ? m_agent : "Abaddon"); -#ifdef USE_LOCAL_PROXY - req.set_proxy("http://127.0.0.1:8888"); - req.set_verify_ssl(false); -#endif auto res = req.execute(); @@ -128,10 +111,6 @@ http::request HTTPClient::CreateRequest(http::EMethod method, std::string path) http::request req(method, m_api_base + path); req.set_header("Authorization", m_authorization); req.set_user_agent(!m_agent.empty() ? m_agent : "Abaddon"); -#ifdef USE_LOCAL_PROXY - req.set_proxy("http://127.0.0.1:8888"); - req.set_verify_ssl(false); -#endif return req; } @@ -163,6 +142,7 @@ void HTTPClient::AddHeaders(http::request &r) { for (const auto &[name, val] : m_headers) { r.set_header(name, val); } + curl_easy_setopt(r.get_curl(), CURLOPT_COOKIE, m_cookie.c_str()); curl_easy_setopt(r.get_curl(), CURLOPT_ACCEPT_ENCODING, "gzip, deflate, br"); } |