diff options
author | George Hazan <ghazan@miranda.im> | 2018-12-27 21:58:20 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-12-27 21:58:20 +0300 |
commit | e30cef77ca9d2a1b49f1eea6cd3d48eed4ba1cce (patch) | |
tree | a716e6801aad9f4971085063decd9f80336acef7 /protocols/Icq10 | |
parent | a68bd126f47dd0b7717c0c5e8a6e6706b63a48bc (diff) |
RAPI error 40201 processing
Diffstat (limited to 'protocols/Icq10')
-rw-r--r-- | protocols/Icq10/src/http.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/protocols/Icq10/src/http.cpp b/protocols/Icq10/src/http.cpp index 7ef26c38de..4681a4d135 100644 --- a/protocols/Icq10/src/http.cpp +++ b/protocols/Icq10/src/http.cpp @@ -111,7 +111,7 @@ void CIcqProto::ExecuteRequest(AsyncHttpRequest *pReq) } else { pReq->dataLength = pReq->m_szParam.GetLength(); - pReq->pData = pReq->m_szParam.Detach(); + pReq->pData = mir_strdup(pReq->m_szParam); } } @@ -136,6 +136,25 @@ void CIcqProto::ExecuteRequest(AsyncHttpRequest *pReq) NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(m_hNetlibUser, pReq); if (reply != nullptr) { + if (pReq->m_conn == CONN_RAPI && reply->pData && strstr(reply->pData, "\"code\": 40201")) { + RobustReply r(reply); + if (r.error() == 40201) { // robust token expired + CMStringA oldToken = m_szRToken; + m_szRToken.Empty(); + delSetting("RToken"); + + // if token refresh succeeded, replace it in the query and push request back + if (RefreshRobustToken()) { + replaceStr(pReq->pData, nullptr); + pReq->dataLength = 0; + pReq->m_szParam.Replace(oldToken, m_szRToken); + Push(pReq); + } + else delete pReq; + return; + } + } + if (pReq->m_pFunc != nullptr) (this->*(pReq->m_pFunc))(reply, pReq); |