From 868b53ce21912343e8fbc556e50283f93efa9fc0 Mon Sep 17 00:00:00 2001 From: Jasper Horn Date: Mon, 10 Feb 2020 02:29:59 +0100 Subject: [PATCH] Improve LittleFS support Previously, when the path was a directory, but didn't have a slash at the end, a 0 byte response would be sent when using LittleFS. Now, it will return a 404, like was always the case when using SPIFFS. --- .../ESP8266WebServer/src/detail/RequestHandlersImpl.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h b/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h index 1c44f7833f..68aa481e0a 100644 --- a/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h +++ b/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h @@ -78,7 +78,7 @@ class StaticRequestHandler : public RequestHandler { else { _isFile = false; } - + DEBUGV("StaticRequestHandler: path=%s uri=%s isFile=%d, cache_header=%s\r\n", path, uri, _isFile, cache_header); _baseUriLength = _uri.length(); } @@ -132,6 +132,11 @@ class StaticRequestHandler : public RequestHandler { if (!f) return false; + if (!f.isFile()) { + f.close(); + return false; + } + if (_cache_header.length() != 0) server.sendHeader("Cache-Control", _cache_header);