Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9f08cf4

Browse filesBrowse 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
Copy full SHA for 9f08cf4

File tree

Expand file treeCollapse file tree

1 file changed

+2
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-1
lines changed

‎libraries/WebServer/src/detail/RequestHandlersImpl.h

Copy file name to clipboardExpand all lines: libraries/WebServer/src/detail/RequestHandlersImpl.h
+2-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.