Skip to content

Commit

Permalink
0.8.141
Browse files Browse the repository at this point in the history
* fix compile
  • Loading branch information
lumapu committed Aug 16, 2024
1 parent f90aacc commit 85f8540
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/web/web.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class Web {
if (CHECK_MASK(mConfig->sys.protectionMask, mask))
checkProtection(request);

AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), zippedHtml, len);
AsyncWebServerResponse *response = beginResponse(request, 200, F("text/html; charset=UTF-8"), zippedHtml, len);
response->addHeader(F("Content-Encoding"), "gzip");
response->addHeader(F("content-type"), "text/html; charset=UTF-8");
if(request->hasParam("v"))
Expand Down Expand Up @@ -343,7 +343,7 @@ class Web {
}
}

AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), login_html, login_html_len);
AsyncWebServerResponse *response = beginResponse(request, 200, F("text/html; charset=UTF-8"), login_html, login_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
request->send(response);
}
Expand All @@ -354,7 +354,7 @@ class Web {
checkProtection(request);
mApp->lock(true);

AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), system_html, system_html_len);
AsyncWebServerResponse *response = beginResponse(request, 200, F("text/html; charset=UTF-8"), system_html, system_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
request->send(response);
}
Expand All @@ -363,9 +363,9 @@ class Web {
DPRINTLN(DBG_VERBOSE, F("onColor"));
AsyncWebServerResponse *response;
if (mConfig->sys.darkMode)
response = request->beginResponse(200, F("text/css"), colorDark_css, colorDark_css_len);
response = beginResponse(request, 200, F("text/css"), colorDark_css, colorDark_css_len);
else
response = request->beginResponse(200, F("text/css"), colorBright_css, colorBright_css_len);
response = beginResponse(request, 200, F("text/css"), colorBright_css, colorBright_css_len);
response->addHeader(F("Content-Encoding"), "gzip");
if(request->hasParam("v")) {
response->addHeader(F("Cache-Control"), F("max-age=604800"));
Expand All @@ -375,7 +375,7 @@ class Web {

void onCss(AsyncWebServerRequest *request) {
DPRINTLN(DBG_VERBOSE, F("onCss"));
AsyncWebServerResponse *response = request->beginResponse(200, F("text/css"), style_css, style_css_len);
AsyncWebServerResponse *response = beginResponse(request, 200, F("text/css"), style_css, style_css_len);
response->addHeader(F("Content-Encoding"), "gzip");
if(request->hasParam("v")) {
response->addHeader(F("Cache-Control"), F("max-age=604800"));
Expand All @@ -386,7 +386,7 @@ class Web {
void onApiJs(AsyncWebServerRequest *request) {
DPRINTLN(DBG_VERBOSE, F("onApiJs"));

AsyncWebServerResponse *response = request->beginResponse(200, F("text/javascript"), api_js, api_js_len);
AsyncWebServerResponse *response = beginResponse(request, 200, F("text/javascript"), api_js, api_js_len);
response->addHeader(F("Content-Encoding"), "gzip");
if(request->hasParam("v"))
response->addHeader(F("Cache-Control"), F("max-age=604800"));
Expand All @@ -396,7 +396,7 @@ class Web {
void onGridInfoJson(AsyncWebServerRequest *request) {
DPRINTLN(DBG_VERBOSE, F("onGridInfoJson"));

AsyncWebServerResponse *response = request->beginResponse(200, F("application/json; charset=utf-8"), grid_info_json, grid_info_json_len);
AsyncWebServerResponse *response = beginResponse(request, 200, F("application/json; charset=utf-8"), grid_info_json, grid_info_json_len);
response->addHeader(F("Content-Encoding"), "gzip");
if(request->hasParam("v"))
response->addHeader(F("Cache-Control"), F("max-age=604800"));
Expand All @@ -405,7 +405,7 @@ class Web {

void onFavicon(AsyncWebServerRequest *request) {
static const char favicon_type[] PROGMEM = "image/x-icon";
AsyncWebServerResponse *response = request->beginResponse(200, favicon_type, favicon_ico, favicon_ico_len);
AsyncWebServerResponse *response = beginResponse(request, 200, favicon_type, favicon_ico, favicon_ico_len);
response->addHeader(F("Content-Encoding"), "gzip");
request->send(response);
}
Expand All @@ -418,15 +418,15 @@ class Web {

void onReboot(AsyncWebServerRequest *request) {
mApp->setRebootFlag();
AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), system_html, system_html_len);
AsyncWebServerResponse *response = beginResponse(request, 200, F("text/html; charset=UTF-8"), system_html, system_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
request->send(response);
}

void showHtml(AsyncWebServerRequest *request) {
checkProtection(request);

AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), system_html, system_html_len);
AsyncWebServerResponse *response = beginResponse(request, 200, F("text/html; charset=UTF-8"), system_html, system_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
request->send(response);
}
Expand All @@ -443,7 +443,7 @@ class Web {
}
#endif

AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), wizard_html, wizard_html_len);
AsyncWebServerResponse *response = beginResponse(request, 200, F("text/html; charset=UTF-8"), wizard_html, wizard_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
response->addHeader(F("content-type"), "text/html; charset=UTF-8");
request->send(response);
Expand Down Expand Up @@ -635,7 +635,7 @@ class Web {

mApp->saveSettings((request->arg("reboot") == "on"));

AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), save_html, save_html_len);
AsyncWebServerResponse *response = beginResponse(request, 200, F("text/html; charset=UTF-8"), save_html, save_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
request->send(response);
}
Expand All @@ -649,7 +649,7 @@ class Web {
}

void onAbout(AsyncWebServerRequest *request) {
AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), about_html, about_html_len);
AsyncWebServerResponse *response = beginResponse(request, 200, F("text/html; charset=UTF-8"), about_html, about_html_len);
response->addHeader(F("Content-Encoding"), "gzip");
response->addHeader(F("content-type"), "text/html; charset=UTF-8");
if(request->hasParam("v")) {
Expand All @@ -673,6 +673,14 @@ class Web {
getPage(request, PROT_MASK_SYSTEM, system_html, system_html_len);
}

AsyncWebServerResponse* beginResponse(AsyncWebServerRequest *request, int code, const String& contentType, const uint8_t * content, size_t len, AwsTemplateProcessor callback=nullptr) {
#if defined(ESP32)
return request->beginResponse(code, contentType, content, len);
#else
return request->beginResponse_P(code, contentType, content, len);
#endif
}


#ifdef ENABLE_PROMETHEUS_EP
// Note
Expand Down

0 comments on commit 85f8540

Please sign in to comment.