summaryrefslogtreecommitdiff
path: root/protocols/Icq10/src/http.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Icq10/src/http.cpp')
-rw-r--r--protocols/Icq10/src/http.cpp44
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);
+}