Skip to content

Commit 9f08cf4

Browse files
authoredJan 31, 2022
Update RequestHandlersImpl.h (#6179)
With LittleFS the `fs.exists(path)` returns true also on folders. A `isDirectory()` call is required to set _isFile to false on directories. This enables serving all files from a folder like : `server->serveStatic("/", LittleFS, "/", cacheHeader.c_str()); File f = fs.open(path); _isFile = (f && (! f.isDirectory()));
1 parent 96a5ddc commit 9f08cf4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

Diff for: ‎libraries/WebServer/src/detail/RequestHandlersImpl.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class StaticRequestHandler : public RequestHandler {
6868
, _path(path)
6969
, _cache_header(cache_header)
7070
{
71-
_isFile = fs.exists(path);
71+
File f = fs.open(path);
72+
_isFile = (f && (! f.isDirectory()));
7273
log_v("StaticRequestHandler: path=%s uri=%s isFile=%d, cache_header=%s\r\n", path, uri, _isFile, cache_header ? cache_header : ""); // issue 5506 - cache_header can be nullptr
7374
_baseUriLength = _uri.length();
7475
}

0 commit comments

Comments
 (0)
Please sign in to comment.