mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-22 23:48:08 -05:00
Fix AsyncWebRequest backwards compat
This commit is contained in:
parent
1718e815d2
commit
83e48fa8dc
2 changed files with 11 additions and 11 deletions
|
@ -106,12 +106,12 @@ namespace geode::utils::web {
|
|||
|
||||
// Hack until 2.0.0 to store extra members in AsyncWebRequest
|
||||
struct AsyncWebRequestData {
|
||||
std::variant<std::monostate, std::ostream*, ghc::filesystem::path> m_target;
|
||||
std::string m_userAgent;
|
||||
std::string m_customRequest;
|
||||
bool m_isPostRequest = false;
|
||||
std::string m_postFields;
|
||||
bool m_isJsonRequest = false;
|
||||
bool m_sent = false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -130,8 +130,8 @@ namespace geode::utils::web {
|
|||
AsyncExpectCode m_expect = nullptr;
|
||||
AsyncProgress m_progress = nullptr;
|
||||
AsyncCancelled m_cancelled = nullptr;
|
||||
bool m_sent = false;
|
||||
mutable std::variant<std::monostate, AsyncWebRequestData> m_extra;
|
||||
AsyncWebRequestData* m_extra = nullptr;
|
||||
std::variant<std::monostate, std::ostream*, ghc::filesystem::path> m_target;
|
||||
std::vector<std::string> m_httpHeaders;
|
||||
|
||||
AsyncWebRequestData& extra();
|
||||
|
|
|
@ -427,17 +427,17 @@ void SentAsyncWebRequest::error(std::string const& error, int code) {
|
|||
}
|
||||
|
||||
AsyncWebRequestData& AsyncWebRequest::extra() {
|
||||
if (!std::holds_alternative<AsyncWebRequestData>(m_extra)) {
|
||||
m_extra = AsyncWebRequestData();
|
||||
if (!m_extra) {
|
||||
m_extra = new AsyncWebRequestData();
|
||||
}
|
||||
return std::get<AsyncWebRequestData>(m_extra);
|
||||
return *m_extra;
|
||||
}
|
||||
|
||||
AsyncWebRequestData const& AsyncWebRequest::extra() const {
|
||||
if (!std::holds_alternative<AsyncWebRequestData>(m_extra)) {
|
||||
m_extra = AsyncWebRequestData();
|
||||
if (!m_extra) {
|
||||
m_extra = new AsyncWebRequestData();
|
||||
}
|
||||
return std::get<AsyncWebRequestData>(m_extra);
|
||||
return *m_extra;
|
||||
}
|
||||
|
||||
AsyncWebRequest& AsyncWebRequest::join(std::string const& requestID) {
|
||||
|
@ -503,8 +503,8 @@ AsyncWebRequest& AsyncWebRequest::cancelled(AsyncCancelled cancelledFunc) {
|
|||
}
|
||||
|
||||
SentAsyncWebRequestHandle AsyncWebRequest::send() {
|
||||
if (m_sent) return nullptr;
|
||||
m_sent = true;
|
||||
if (this->extra().m_sent) return nullptr;
|
||||
this->extra().m_sent = true;
|
||||
|
||||
std::lock_guard __(RUNNING_REQUESTS_MUTEX);
|
||||
|
||||
|
|
Loading…
Reference in a new issue