summaryrefslogtreecommitdiff
path: root/src/discord/httpclient.cpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2022-06-05 21:41:57 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2022-06-05 21:41:57 -0400
commit270730d9b36c8fc3a221da7e565632c1432d41c6 (patch)
treeed67d9fcec4df6287f3dd13cb997297d6af50ec8 /src/discord/httpclient.cpp
parent4ec5c1dfccaa5ce3bce5dc22a95e91d781262345 (diff)
downloadabaddon-portaudio-270730d9b36c8fc3a221da7e565632c1432d41c6.tar.gz
abaddon-portaudio-270730d9b36c8fc3a221da7e565632c1432d41c6.zip
start attachments (image paste and upload)
Diffstat (limited to 'src/discord/httpclient.cpp')
-rw-r--r--src/discord/httpclient.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/discord/httpclient.cpp b/src/discord/httpclient.cpp
index f5b640c..6646bf3 100644
--- a/src/discord/httpclient.cpp
+++ b/src/discord/httpclient.cpp
@@ -112,6 +112,25 @@ void HTTPClient::MakeGET(const std::string &path, const std::function<void(http:
}));
}
+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;
+}
+
+void HTTPClient::Execute(http::request &&req, const std::function<void(http::response_type r)> &cb) {
+ printf("%s %s\n", req.get_method(), req.get_url().c_str());
+ m_futures.push_back(std::async(std::launch::async, [this, cb, req = std::move(req)]() mutable {
+ auto res = req.execute();
+ OnResponse(res, cb);
+ }));
+}
+
void HTTPClient::CleanupFutures() {
for (auto it = m_futures.begin(); it != m_futures.end();) {
if (it->wait_for(std::chrono::seconds(0)) == std::future_status::ready)