From 94667140aeb3886d22e4c1301423fe99aaf3fba4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 4 Jan 2024 13:38:02 +0300 Subject: Netlib: pascal code is completely isolated from C++ core using helpers --- protocols/Discord/src/gateway.cpp | 7 +------ protocols/Discord/src/server.cpp | 13 +------------ protocols/ICQ-WIM/src/mra.cpp | 13 +------------ protocols/Tox/src/http_request.h | 1 - 4 files changed, 3 insertions(+), 31 deletions(-) (limited to 'protocols') diff --git a/protocols/Discord/src/gateway.cpp b/protocols/Discord/src/gateway.cpp index 543020f105..e76de2848a 100644 --- a/protocols/Discord/src/gateway.cpp +++ b/protocols/Discord/src/gateway.cpp @@ -61,12 +61,7 @@ bool CDiscordProto::GatewayThreadWorker() return false; } - if (auto *pszNewCookie = Netlib_GetHeader(pReply, "Set-Cookie")) { - char *p = strchr(pszNewCookie, ';'); - if (p) *p = 0; - - m_szWSCookie = pszNewCookie; - } + m_szWSCookie = pReply->GetCookies(); if (pReply->resultCode != 101) { // if there's no cookie & Miranda is bounced with error 404, simply apply the cookie and try again diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp index 243e80d2b2..1ef3517822 100644 --- a/protocols/Discord/src/server.cpp +++ b/protocols/Discord/src/server.cpp @@ -165,18 +165,7 @@ void CDiscordProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest* m_wszEmail = data["email"].as_mstring(); m_ownId = id; - - m_szCookie.Empty(); - for (int i=0; i < pReply->headersCount; i++) { - if (!mir_strcmpi(pReply->headers[i].szName, "Set-Cookie")) { - char *p = strchr(pReply->headers[i].szValue, ';'); - if (p) *p = 0; - if (!m_szCookie.IsEmpty()) - m_szCookie.Append("; "); - - m_szCookie.Append(pReply->headers[i].szValue); - } - } + m_szCookie = pReply->GetCookies(); // launch gateway thread if (m_szGateway.IsEmpty()) diff --git a/protocols/ICQ-WIM/src/mra.cpp b/protocols/ICQ-WIM/src/mra.cpp index cfe427a136..b65ae238dc 100644 --- a/protocols/ICQ-WIM/src/mra.cpp +++ b/protocols/ICQ-WIM/src/mra.cpp @@ -19,18 +19,7 @@ along with this program. If not, see . void CIcqProto::SendMrimLogin(NETLIBHTTPREQUEST *pReply) { - if (pReply) { - for (int i=0; i < pReply->headersCount; i++) { - if (!mir_strcmpi(pReply->headers[i].szName, "Set-Cookie")) { - char *p = strchr(pReply->headers[i].szValue, ';'); - if (p) *p = 0; - if (!m_szMraCookie.IsEmpty()) - m_szMraCookie.Append("; "); - - m_szMraCookie.Append(pReply->headers[i].szValue); - } - } - } + m_szMraCookie = pReply->GetCookies(); auto *pReq = new AsyncHttpRequest(CONN_NONE, REQUEST_POST, "https://icqapilogin.mail.ru/auth/mrimLogin", &CIcqProto::OnCheckMrimLogin); pReq->AddHeader("User-Agent", NETLIB_USER_AGENT); diff --git a/protocols/Tox/src/http_request.h b/protocols/Tox/src/http_request.h index d51aab289f..bba9f0591c 100644 --- a/protocols/Tox/src/http_request.h +++ b/protocols/Tox/src/http_request.h @@ -24,7 +24,6 @@ private: void Init(int type) { - cbSize = sizeof(NETLIBHTTPREQUEST); requestType = type; flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT; szUrl = nullptr; -- cgit v1.2.3