From c75e6bcfac1875c4462657cb6ca00cbc02752409 Mon Sep 17 00:00:00 2001 From: Jasper Horn Date: Sat, 4 Jan 2020 20:09:07 +0100 Subject: [PATCH 1/2] Remove trailing whitespace --- libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h b/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h index fb7bbb84d8..80549b4174 100644 --- a/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h +++ b/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h @@ -96,7 +96,7 @@ class StaticRequestHandler : public RequestHandler { if (!_isFile) { // Base URI doesn't point to a file. // If a directory is requested, look for index file. - if (requestUri.endsWith("/")) + if (requestUri.endsWith("/")) requestUri += "index.htm"; // Append whatever follows this URI in request to get the file path. From cf18199ea17ae4ba078ef2eddf2f7475f5047230 Mon Sep 17 00:00:00 2001 From: Jasper Horn Date: Sat, 4 Jan 2020 20:10:53 +0100 Subject: [PATCH 2/2] Improve "is file" check for LittleFS support The previous implementation was based on a quirk of SPIFFS (that exists returns false for directories) so it wouldn't work with LittleFS. This implementation works with both. --- .../ESP8266WebServer/src/detail/RequestHandlersImpl.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h b/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h index 80549b4174..b29f159a37 100644 --- a/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h +++ b/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h @@ -70,7 +70,15 @@ class StaticRequestHandler : public RequestHandler { , _path(path) , _cache_header(cache_header) { - _isFile = fs.exists(path); + if (fs.exists(path)) { + File file = fs.open(path, "r"); + _isFile = file && file.isFile(); + file.close(); + } + else { + _isFile = false; + } + DEBUGV("StaticRequestHandler: path=%s uri=%s isFile=%d, cache_header=%s\r\n", path, uri, _isFile, cache_header); _baseUriLength = _uri.length(); }