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
12 changes: 10 additions & 2 deletions libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ class StaticRequestHandler : public RequestHandler<ServerType> {
, _path(path)
, _cache_header(cache_header)
{
_isFile = fs.exists(path);
if (fs.exists(path)) {
File file = fs.open(path, "r");
_isFile = file && file.isFile();
file.close();
}
else {
_isFile = false;
}

DEBUGV("StaticRequestHandler: path=%s uri=%s isFile=%d, cache_header=%s\r\n", path, uri, _isFile, cache_header);
_baseUriLength = _uri.length();
}
Expand All @@ -96,7 +104,7 @@ class StaticRequestHandler : public RequestHandler<ServerType> {
if (!_isFile) {
// Base URI doesn't point to a file.
// If a directory is requested, look for index file.
if (requestUri.endsWith("/"))
if (requestUri.endsWith("/"))
requestUri += "index.htm";

// Append whatever follows this URI in request to get the file path.
Expand Down