Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update RequestHandlersImpl.h
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()));
  • Loading branch information
mathertel authored Jan 22, 2022
commit 1dc211afa7a034f61c3657c048fbe7db43ad7ba7
3 changes: 2 additions & 1 deletion libraries/WebServer/src/detail/RequestHandlersImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class StaticRequestHandler : public RequestHandler {
, _path(path)
, _cache_header(cache_header)
{
_isFile = fs.exists(path);
File f = fs.open(path);
_isFile = (f && (! f.isDirectory()));
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
_baseUriLength = _uri.length();
}
Expand Down