mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2026-12-01 08:07:08 +01:00
Update WIP discord and some vendors.
CPR has features disabled and PCRE is fully disabled until updated to new code.
This commit is contained in:
1 parent
e0761bf3b9
commit
9298065cef
1562 files changed
+55070
-76299
No files matched your search
Vendored
+12
-11
@@ -35,17 +35,19 @@ namespace dpp {
|
||||
static std::string http_version = "DiscordBot (https://github.com/brainboxdotcc/DPP, " + std::to_string(DPP_VERSION_MAJOR) + "." + std::to_string(DPP_VERSION_MINOR) + "." + std::to_string(DPP_VERSION_PATCH) + ")";
|
||||
static const char* DISCORD_HOST = "https://discord.com";
|
||||
|
||||
http_request::http_request(const std::string &_endpoint, const std::string &_parameters, http_completion_event completion, const std::string &_postdata, http_method _method, const std::string &audit_reason, const std::string &filename, const std::string &filecontent)
|
||||
http_request::http_request(const std::string &_endpoint, const std::string &_parameters, http_completion_event completion, const std::string &_postdata, http_method _method, const std::string &audit_reason, const std::string &filename, const std::string &filecontent, const std::string &filemimetype)
|
||||
: complete_handler(completion), completed(false), non_discord(false), endpoint(_endpoint), parameters(_parameters), postdata(_postdata), method(_method), reason(audit_reason), mimetype("application/json"), waiting(false)
|
||||
{
|
||||
if (!filename.empty())
|
||||
file_name.push_back(filename);
|
||||
if (!filecontent.empty())
|
||||
file_content.push_back(filecontent);
|
||||
if (!filemimetype.empty())
|
||||
file_mimetypes.push_back(filemimetype);
|
||||
}
|
||||
|
||||
http_request::http_request(const std::string &_endpoint, const std::string &_parameters, http_completion_event completion, const std::string &_postdata, http_method method, const std::string &audit_reason, const std::vector<std::string> &filename, const std::vector<std::string> &filecontent)
|
||||
: complete_handler(completion), completed(false), non_discord(false), endpoint(_endpoint), parameters(_parameters), postdata(_postdata), method(method), reason(audit_reason), file_name(filename), file_content(filecontent), mimetype("application/json"), waiting(false)
|
||||
http_request::http_request(const std::string &_endpoint, const std::string &_parameters, http_completion_event completion, const std::string &_postdata, http_method method, const std::string &audit_reason, const std::vector<std::string> &filename, const std::vector<std::string> &filecontent, const std::vector<std::string> &filemimetypes)
|
||||
: complete_handler(completion), completed(false), non_discord(false), endpoint(_endpoint), parameters(_parameters), postdata(_postdata), method(method), reason(audit_reason), file_name(filename), file_content(filecontent), file_mimetypes(filemimetypes), mimetype("application/json"), waiting(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -68,7 +70,7 @@ void populate_result(const std::string &url, cluster* owner, http_request_comple
|
||||
rv.status = res.get_status();
|
||||
rv.body = res.get_content();
|
||||
for (auto &v : res.get_headers()) {
|
||||
rv.headers[v.first] = v.second;
|
||||
rv.headers.emplace(v.first, v.second);
|
||||
}
|
||||
|
||||
/* This will be ignored for non-discord requests without rate limit headers */
|
||||
@@ -78,7 +80,7 @@ void populate_result(const std::string &url, cluster* owner, http_request_comple
|
||||
rv.ratelimit_reset_after = from_string<uint64_t>(res.get_header("x-ratelimit-reset-after"));
|
||||
rv.ratelimit_bucket = res.get_header("x-ratelimit-bucket");
|
||||
rv.ratelimit_global = (res.get_header("x-ratelimit-global") == "true");
|
||||
owner->rest_ping = rv.latency;
|
||||
owner->rest_ping = rv.latency;
|
||||
if (res.get_header("x-ratelimit-retry-after") != "") {
|
||||
rv.ratelimit_retry_after = from_string<uint64_t>(res.get_header("x-ratelimit-retry-after"));
|
||||
}
|
||||
@@ -164,13 +166,12 @@ http_request_completion_t http_request::run(cluster* owner) {
|
||||
|
||||
multipart_content multipart;
|
||||
if (non_discord) {
|
||||
multipart = { postdata, "" };
|
||||
multipart = { postdata, mimetype };
|
||||
} else {
|
||||
|
||||
multipart = https_client::build_multipart(postdata, file_name, file_content);
|
||||
if (!multipart.mimetype.empty()) {
|
||||
headers.emplace("Content-Type", multipart.mimetype);
|
||||
}
|
||||
multipart = https_client::build_multipart(postdata, file_name, file_content, file_mimetypes);
|
||||
}
|
||||
if (!multipart.mimetype.empty()) {
|
||||
headers.emplace("Content-Type", multipart.mimetype);
|
||||
}
|
||||
http_connect_info hci = https_client::get_host_info(_host);
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user