Skip to content

Commit 9f08cf4

Browse files
authored
Update RequestHandlersImpl.h (espressif#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

libraries/WebServer/src/detail/RequestHandlersImpl.h

Lines changed: 2 additions & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy