diff options
author | George Hazan <ghazan@miranda.im> | 2020-01-13 16:48:55 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-01-13 16:48:55 +0300 |
commit | 87a2660299edd64cbb6f6c92c33683e91a6d187c (patch) | |
tree | a1b0777ec5b8afc0c49fbb66cf6a122b5ac82c6d /protocols/Weather/src | |
parent | 21f52dbfa251d171b4cc9dc315e8736da2e2be08 (diff) |
Netlib_GetHeader() - handful utility to avoid writing cycles
Diffstat (limited to 'protocols/Weather/src')
-rw-r--r-- | protocols/Weather/src/weather_http.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
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; |