@@ -245,7 +245,7 @@ class Web {
245
245
if (CHECK_MASK (mConfig ->sys .protectionMask , mask))
246
246
checkProtection (request);
247
247
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);
249
249
response->addHeader (F (" Content-Encoding" ), " gzip" );
250
250
response->addHeader (F (" content-type" ), " text/html; charset=UTF-8" );
251
251
if (request->hasParam (" v" ))
@@ -343,7 +343,7 @@ class Web {
343
343
}
344
344
}
345
345
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);
347
347
response->addHeader (F (" Content-Encoding" ), " gzip" );
348
348
request->send (response);
349
349
}
@@ -354,7 +354,7 @@ class Web {
354
354
checkProtection (request);
355
355
mApp ->lock (true );
356
356
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);
358
358
response->addHeader (F (" Content-Encoding" ), " gzip" );
359
359
request->send (response);
360
360
}
@@ -363,9 +363,9 @@ class Web {
363
363
DPRINTLN (DBG_VERBOSE, F (" onColor" ));
364
364
AsyncWebServerResponse *response;
365
365
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);
367
367
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);
369
369
response->addHeader (F (" Content-Encoding" ), " gzip" );
370
370
if (request->hasParam (" v" )) {
371
371
response->addHeader (F (" Cache-Control" ), F (" max-age=604800" ));
@@ -375,7 +375,7 @@ class Web {
375
375
376
376
void onCss (AsyncWebServerRequest *request) {
377
377
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);
379
379
response->addHeader (F (" Content-Encoding" ), " gzip" );
380
380
if (request->hasParam (" v" )) {
381
381
response->addHeader (F (" Cache-Control" ), F (" max-age=604800" ));
@@ -386,7 +386,7 @@ class Web {
386
386
void onApiJs (AsyncWebServerRequest *request) {
387
387
DPRINTLN (DBG_VERBOSE, F (" onApiJs" ));
388
388
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);
390
390
response->addHeader (F (" Content-Encoding" ), " gzip" );
391
391
if (request->hasParam (" v" ))
392
392
response->addHeader (F (" Cache-Control" ), F (" max-age=604800" ));
@@ -396,7 +396,7 @@ class Web {
396
396
void onGridInfoJson (AsyncWebServerRequest *request) {
397
397
DPRINTLN (DBG_VERBOSE, F (" onGridInfoJson" ));
398
398
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);
400
400
response->addHeader (F (" Content-Encoding" ), " gzip" );
401
401
if (request->hasParam (" v" ))
402
402
response->addHeader (F (" Cache-Control" ), F (" max-age=604800" ));
@@ -405,7 +405,7 @@ class Web {
405
405
406
406
void onFavicon (AsyncWebServerRequest *request) {
407
407
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);
409
409
response->addHeader (F (" Content-Encoding" ), " gzip" );
410
410
request->send (response);
411
411
}
@@ -418,15 +418,15 @@ class Web {
418
418
419
419
void onReboot (AsyncWebServerRequest *request) {
420
420
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);
422
422
response->addHeader (F (" Content-Encoding" ), " gzip" );
423
423
request->send (response);
424
424
}
425
425
426
426
void showHtml (AsyncWebServerRequest *request) {
427
427
checkProtection (request);
428
428
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);
430
430
response->addHeader (F (" Content-Encoding" ), " gzip" );
431
431
request->send (response);
432
432
}
@@ -443,7 +443,7 @@ class Web {
443
443
}
444
444
#endif
445
445
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);
447
447
response->addHeader (F (" Content-Encoding" ), " gzip" );
448
448
response->addHeader (F (" content-type" ), " text/html; charset=UTF-8" );
449
449
request->send (response);
@@ -635,7 +635,7 @@ class Web {
635
635
636
636
mApp ->saveSettings ((request->arg (" reboot" ) == " on" ));
637
637
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);
639
639
response->addHeader (F (" Content-Encoding" ), " gzip" );
640
640
request->send (response);
641
641
}
@@ -649,7 +649,7 @@ class Web {
649
649
}
650
650
651
651
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);
653
653
response->addHeader (F (" Content-Encoding" ), " gzip" );
654
654
response->addHeader (F (" content-type" ), " text/html; charset=UTF-8" );
655
655
if (request->hasParam (" v" )) {
@@ -673,6 +673,14 @@ class Web {
673
673
getPage (request, PROT_MASK_SYSTEM, system_html, system_html_len);
674
674
}
675
675
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
+
676
684
677
685
#ifdef ENABLE_PROMETHEUS_EP
678
686
// Note
0 commit comments