From 87a2660299edd64cbb6f6c92c33683e91a6d187c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 13 Jan 2020 16:48:55 +0300 Subject: Netlib_GetHeader() - handful utility to avoid writing cycles --- protocols/Discord/src/gateway.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'protocols/Discord/src/gateway.cpp') diff --git a/protocols/Discord/src/gateway.cpp b/protocols/Discord/src/gateway.cpp index fae8eef7cc..6b5e320904 100644 --- a/protocols/Discord/src/gateway.cpp +++ b/protocols/Discord/src/gateway.cpp @@ -56,15 +56,13 @@ bool CDiscordProto::GatewayThreadWorker() debugLogA("Gateway connection succeeded"); m_hGatewayConnection = pReply->nlc; - for (int i=0; i < pReply->headersCount; i++) - if (!mir_strcmp(pReply->headers[i].szName, "Set-Cookie")) { - m_szCookie = pReply->headers[i].szValue; + if (auto *pszHdr = Netlib_GetHeader(pReply, "Set-Cookie")) { + m_szCookie = pszHdr; - int idx = m_szCookie.Find(';'); - if (idx != -1) - m_szCookie.Truncate(idx); - break; - } + int idx = m_szCookie.Find(';'); + if (idx != -1) + m_szCookie.Truncate(idx); + } Netlib_FreeHttpRequest(pReply); bool bExit = false; -- cgit v1.2.3