diff options
author | George Hazan <ghazan@miranda.im> | 2020-05-01 19:03:20 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-05-01 19:03:20 +0300 |
commit | c07739c95595eca57dcf2651f42511ac87c45a3b (patch) | |
tree | 2ec01c9ac163b67ad8a56c4bf1d5eaadeb4ac1ea | |
parent | c9027518b426a134006a7335184df8f9205b2938 (diff) |
Discord: if http connection got expired, a request shall be resent
-rw-r--r-- | protocols/Discord/src/connection.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/protocols/Discord/src/connection.cpp b/protocols/Discord/src/connection.cpp index 208bb1be79..cd4f705272 100644 --- a/protocols/Discord/src/connection.cpp +++ b/protocols/Discord/src/connection.cpp @@ -39,16 +39,12 @@ void CDiscordProto::ExecuteRequest(AsyncHttpRequest *pReq) pReq->AddHeader("Cookie", m_szCookie); } + bool bRetryable = pReq->nlc != nullptr; debugLogA("Executing request #%d:\n%s", pReq->m_iReqNum, pReq->szUrl); - NLHR_PTR reply(Netlib_HttpTransaction(m_hNetlibUser, pReq)); - if (reply != nullptr) { - if (pReq->m_pFunc != nullptr) - (this->*(pReq->m_pFunc))(reply, pReq); - if (pReq->m_bMainSite) - m_hAPIConnection = reply->nlc; - } - else { +LBL_Retry: + NLHR_PTR reply(Netlib_HttpTransaction(m_hNetlibUser, pReq)); + if (reply == nullptr) { debugLogA("Request %d failed", pReq->m_iReqNum); if (pReq->m_bMainSite) { @@ -56,6 +52,20 @@ void CDiscordProto::ExecuteRequest(AsyncHttpRequest *pReq) ConnectionFailed(LOGINERR_NONETWORK); m_hAPIConnection = nullptr; } + + if (bRetryable) { + debugLogA("Attempt to retry request #%d", pReq->m_iReqNum); + pReq->nlc = nullptr; + bRetryable = false; + goto LBL_Retry; + } + } + else { + if (pReq->m_pFunc != nullptr) + (this->*(pReq->m_pFunc))(reply, pReq); + + if (pReq->m_bMainSite) + m_hAPIConnection = reply->nlc; } delete pReq; } |