Skip to content

Commit c4f3305

Browse files
committed
Fix crash when serving content on ESP8266 from flash file system with ESP Async WebServer library fork by ESP32Async
1 parent f324e2f commit c4f3305

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

VanLiveConnect/VanLiveConnect.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
// We need access to class AsyncWebSocketClient private members _runQueue() and _messageQueue
2020
#define private public
21-
#ifdef USE_OLD_ESP_ASYNC_WEB_SERVER // See line 216 of Config.h
21+
#ifdef USE_OLD_ESP_ASYNC_WEB_SERVER // See line 220 of Config.h
2222
#include <ESPAsyncWebSrv.h> // https://github.com/dvarrel/ESPAsyncWebSrv
2323
#else
24-
#include <ESPAsyncWebServer.h> // https://github.com/ESP32Async/ESPAsyncWebServer or https://github.com/lacamera/ESPAsyncWebServer
24+
#include <ESPAsyncWebServer.h> // https://github.com/ESP32Async/ESPAsyncWebServer
2525
#endif
2626
#undef private
2727

VanLiveConnect/WebServer.ino

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,15 @@ void HandleAndroidConnectivityCheck(class AsyncWebServerRequest* request)
312312
// -----
313313
// MIME type string constants
314314

315-
static const char PROGMEM textJavaScriptStr[] = "text/javascript";
316-
static const char PROGMEM textCssStr[] = "text/css";
317-
static const char PROGMEM fontWoffStr[] = "font/woff";
315+
static const char textHtmlStr[] = "text/html";
316+
static const char textJavaScriptStr[] = "text/javascript";
317+
static const char textCssStr[] = "text/css";
318+
static const char fontWoffStr[] = "font/woff";
318319

319320
// Convert the file extension to the MIME type
320321
const char* getContentType(const String& path)
321322
{
322-
if (path.endsWith(".html")) return "text/html";
323+
if (path.endsWith(".html")) return textHtmlStr;
323324
if (path.endsWith(".woff")) return fontWoffStr;
324325
if (path.endsWith(".css")) return textCssStr;
325326
if (path.endsWith(".js")) return textJavaScriptStr;
@@ -430,9 +431,9 @@ void HandleNotFound(class AsyncWebServerRequest* request)
430431
void HandleLowMemory(class AsyncWebServerRequest* request)
431432
{
432433
#if defined USE_OLD_ESP_ASYNC_WEB_SERVER || defined ESP8266
433-
AsyncWebServerResponse* response = request->beginResponse_P(429, F("text/html"),
434+
AsyncWebServerResponse* response = request->beginResponse_P(429, textHtmlStr,
434435
#else
435-
AsyncWebServerResponse* response = request->beginResponse(429, F("text/html"),
436+
AsyncWebServerResponse* response = request->beginResponse(429, textHtmlStr,
436437
#endif
437438
PSTR(
438439
"<html>"
@@ -646,7 +647,7 @@ void ServeMainHtml(class AsyncWebServerRequest* request)
646647
#else
647648

648649
// Serve from program memory, so updating is easy and does not need the flash file system uploader
649-
ServeDocument(request, PSTR("text/html"), mfd_html);
650+
ServeDocument(request, textHtmlStr, mfd_html);
650651

651652
#endif // SERVE_MAIN_FILES_FROM_FFS
652653
} // ServeMainHtml

0 commit comments

Comments
 (0)