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/Weather/src/weather_http.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'protocols/Weather/src') diff --git a/protocols/Weather/src/weather_http.cpp b/protocols/Weather/src/weather_http.cpp index b0672282c1..5ef55cd7e8 100644 --- a/protocols/Weather/src/weather_http.cpp +++ b/protocols/Weather/src/weather_http.cpp @@ -27,16 +27,6 @@ from the web using netlib HNETLIBUSER hNetlibUser; -static int findHeader(const NETLIBHTTPREQUEST *nlhrReply, const char *hdr) -{ - for (int i = 0; i < nlhrReply->headersCount; i++) { - if (_stricmp(nlhrReply->headers[i].szName, hdr) == 0) { - return i; - } - } - return -1; -} - //============ DOWNLOAD NEW WEATHER ============ // // function to download webpage from the internet @@ -90,9 +80,9 @@ int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **s result = 0; // allocate memory and save the retrieved data - int i = findHeader(nlhrReply, "Content-Type"); + auto *pszHdr = Netlib_GetHeader(nlhrReply, "Content-Type"); // look for Content-Type=utf-8 in header - if (i != -1 && strstr(_strlwr(nlhrReply->headers[i].szValue), "utf-8")) + if (pszHdr && strstr(pszHdr, "utf-8")) bIsUtf = true; else { char *end = nlhrReply->pData; -- cgit v1.2.3