From 96e3d5ff4a16da5476e6f1fdd43c77b2b18b2fea Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Sun, 9 Feb 2020 09:37:17 -0800 Subject: [PATCH] Fix serach order for index.htm(l)(.gz) files 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 --- libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h b/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h index b29f159a37..1c44f7833f 100644 --- a/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h +++ b/libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h @@ -110,7 +110,9 @@ class StaticRequestHandler : public RequestHandler { // Append whatever follows this URI in request to get the file path. path += requestUri.substring(_baseUriLength); - if (!_fs.exists(path) && path.endsWith(".htm") && _fs.exists(path + "l")) { + // If neither nor .gz exist, and is a file.htm, try it with file.html instead + // For the normal case this will give a search order of index.htm, index.htm.gz, index.html, index.html.gz + if (!_fs.exists(path) && !_fs.exists(path + ".gz") && path.endsWith(".htm")) { path += "l"; } }