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()));
This commit is contained in:
Matthias Hertel
2022-01-31 12:09:04 +01:00
committed by GitHub
parent 96a5ddcd0e
commit 9f08cf4767

View File

@ -68,7 +68,8 @@ public:
, _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();
}