| 1161 | } |
| 1162 | |
| 1163 | int getImgURL(String &filename, String URL, time_t fetched, imgParam &imageParams, String MAC) { |
| 1164 | // https://images.klari.net/kat-bw29.jpg |
| 1165 | |
| 1166 | HTTPClient http; |
| 1167 | logLine("http getImgURL " + URL); |
| 1168 | http.begin(URL); |
| 1169 | http.addHeader("If-Modified-Since", formatHttpDate(fetched)); |
| 1170 | http.addHeader("X-ESL-MAC", MAC); |
| 1171 | http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS); |
| 1172 | http.setTimeout(5000); // timeout in ms |
| 1173 | const int httpCode = http.GET(); |
| 1174 | if (httpCode == 200) { |
| 1175 | xSemaphoreTake(fsMutex, portMAX_DELAY); |
| 1176 | File f = contentFS->open("/temp/temp.jpg", "w"); |
| 1177 | if (f) { |
| 1178 | http.writeToStream(&f); |
| 1179 | f.close(); |
| 1180 | xSemaphoreGive(fsMutex); |
| 1181 | jpg2buffer("/temp/temp.jpg", filename, imageParams); |
| 1182 | } else { |
| 1183 | xSemaphoreGive(fsMutex); |
| 1184 | } |
| 1185 | } else { |
| 1186 | if (httpCode != 304) { |
| 1187 | wsErr("http " + URL + " " + String(httpCode)); |
| 1188 | } |
| 1189 | } |
| 1190 | http.end(); |
| 1191 | return httpCode; |
| 1192 | } |
| 1193 | |
| 1194 | #ifdef CONTENT_RSS |
| 1195 | rssClass reader; |
no test coverage detected