Skip to content

Commit dbd7b82

Browse files
Fix serach order for index.htm(l)(.gz) files (#7069)
Fixes #6984 When a directory index is requested with an explicit index.html, follow the original webserver order and check for: index.htm, index.htm.gz, index.html, index.html.gz, in order. Fixes the regressions introduced in 9f2cfb8 and 6768116
1 parent 56b90a2 commit dbd7b82

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ class StaticRequestHandler : public RequestHandler<ServerType> {
110110
// Append whatever follows this URI in request to get the file path.
111111
path += requestUri.substring(_baseUriLength);
112112

113-
if (!_fs.exists(path) && path.endsWith(".htm") && _fs.exists(path + "l")) {
113+
// If neither <blah> nor <blah>.gz exist, and <blah> is a file.htm, try it with file.html instead
114+
// For the normal case this will give a search order of index.htm, index.htm.gz, index.html, index.html.gz
115+
if (!_fs.exists(path) && !_fs.exists(path + ".gz") && path.endsWith(".htm")) {
114116
path += "l";
115117
}
116118
}

0 commit comments

Comments
 (0)