MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / getImgURL

Function getImgURL

ESP32_AP-Flasher/src/contentmanager.cpp:1163–1192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1161}
1162
1163int 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
1195rssClass reader;

Callers 1

drawNewFunction · 0.85

Calls 8

logLineFunction · 0.85
formatHttpDateFunction · 0.85
jpg2bufferFunction · 0.85
wsErrFunction · 0.85
openMethod · 0.80
closeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected