diff options
author | George Hazan <ghazan@miranda.im> | 2018-12-27 20:53:58 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-12-27 20:54:07 +0300 |
commit | 38af197ebf6ff9f947d02338262ad8ebe48f26d3 (patch) | |
tree | d6729c86ee940118a8218028bf095c84113b2efa /protocols/Icq10/src/http.cpp | |
parent | 7b4ac22ea5d0d655d302b0edcb753889d5f39fd6 (diff) |
fixes #1668 (ICQ: contact search)
Diffstat (limited to 'protocols/Icq10/src/http.cpp')
-rw-r--r-- | protocols/Icq10/src/http.cpp | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/protocols/Icq10/src/http.cpp b/protocols/Icq10/src/http.cpp index e538450ee5..7ef26c38de 100644 --- a/protocols/Icq10/src/http.cpp +++ b/protocols/Icq10/src/http.cpp @@ -110,8 +110,8 @@ void CIcqProto::ExecuteRequest(AsyncHttpRequest *pReq) pReq->szUrl = str.GetBuffer(); } else { - pReq->pData = mir_strdup(pReq->m_szParam); pReq->dataLength = pReq->m_szParam.GetLength(); + pReq->pData = pReq->m_szParam.Detach(); } } @@ -121,7 +121,19 @@ void CIcqProto::ExecuteRequest(AsyncHttpRequest *pReq) } debugLogA("Executing request %s:\n%s", pReq->m_reqId, pReq->szUrl); - + + if (pReq->m_conn == CONN_RAPI) { + CMStringA szAgent(FORMAT, "%d Mail.ru Windows ICQ (version 10.0.1999)", DWORD(m_dwUin)); + pReq->AddHeader("User-Agent", szAgent); + + if (m_szRToken.IsEmpty()) { + if (!RefreshRobustToken()) { + delete pReq; + return; + } + } + } + NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(m_hNetlibUser, pReq); if (reply != nullptr) { if (pReq->m_pFunc != nullptr) @@ -187,3 +199,31 @@ JsonReply::~JsonReply() { json_delete(m_root); } + +///////////////////////////////////////////////////////////////////////////////////////// + +RobustReply::RobustReply(NETLIBHTTPREQUEST *pReply) +{ + if (pReply == nullptr) { + m_errorCode = 500; + return; + } + + m_errorCode = pReply->resultCode; + if (m_errorCode != 200) + return; + + m_root = json_parse(pReply->pData); + if (m_root == nullptr) { + m_errorCode = 500; + return; + } + + m_errorCode = (*m_root)["status"]["code"].as_int(); + m_results = &(*m_root)["results"]; +} + +RobustReply::~RobustReply() +{ + json_delete(m_root); +} |