Skip to content

Commit 85f8540

Browse files
committed
0.8.141
* fix compile
1 parent f90aacc commit 85f8540

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/web/web.h

+22-14
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class Web {
245245
if (CHECK_MASK(mConfig->sys.protectionMask, mask))
246246
checkProtection(request);
247247

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

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

357-
AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), system_html, system_html_len);
357+
AsyncWebServerResponse *response = beginResponse(request, 200, F("text/html; charset=UTF-8"), system_html, system_html_len);
358358
response->addHeader(F("Content-Encoding"), "gzip");
359359
request->send(response);
360360
}
@@ -363,9 +363,9 @@ class Web {
363363
DPRINTLN(DBG_VERBOSE, F("onColor"));
364364
AsyncWebServerResponse *response;
365365
if (mConfig->sys.darkMode)
366-
response = request->beginResponse(200, F("text/css"), colorDark_css, colorDark_css_len);
366+
response = beginResponse(request, 200, F("text/css"), colorDark_css, colorDark_css_len);
367367
else
368-
response = request->beginResponse(200, F("text/css"), colorBright_css, colorBright_css_len);
368+
response = beginResponse(request, 200, F("text/css"), colorBright_css, colorBright_css_len);
369369
response->addHeader(F("Content-Encoding"), "gzip");
370370
if(request->hasParam("v")) {
371371
response->addHeader(F("Cache-Control"), F("max-age=604800"));
@@ -375,7 +375,7 @@ class Web {
375375

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

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

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

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

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

426426
void showHtml(AsyncWebServerRequest *request) {
427427
checkProtection(request);
428428

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

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

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

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

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

676+
AsyncWebServerResponse* beginResponse(AsyncWebServerRequest *request, int code, const String& contentType, const uint8_t * content, size_t len, AwsTemplateProcessor callback=nullptr) {
677+
#if defined(ESP32)
678+
return request->beginResponse(code, contentType, content, len);
679+
#else
680+
return request->beginResponse_P(code, contentType, content, len);
681+
#endif
682+
}
683+
676684

677685
#ifdef ENABLE_PROMETHEUS_EP
678686
// Note

0 commit comments

Comments
 (0)