From 374be7b0654dce3661c7788378e11060813170af Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Wed, 10 Aug 2022 15:54:24 -0300 Subject: [PATCH] check for gzipped index file when / is requested --- mongoose.c | 4 ++++ src/http.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/mongoose.c b/mongoose.c index 4a0c9f68..b692dbf4 100644 --- a/mongoose.c +++ b/mongoose.c @@ -2097,6 +2097,10 @@ static int uri_to_path2(struct mg_connection *c, struct mg_http_message *hm, (mg_snprintf(path + n, path_size - n, "/index.shtml") > 0 && (tmp = fs->st(path, NULL, NULL)) != 0))) { flags = tmp; + } else if ((mg_snprintf(path + n, path_size - n, "/" MG_HTTP_INDEX ".gz") > 0 && + (tmp = fs->st(path, NULL, NULL)) != 0)) { + flags = tmp; + path[n + 1 + strlen(MG_HTTP_INDEX)] = '\0'; // Remove appended .gz } else { path[n] = '\0'; // Remove appended index file name } diff --git a/src/http.c b/src/http.c index e2362bbc..d795aef6 100644 --- a/src/http.c +++ b/src/http.c @@ -675,6 +675,10 @@ static int uri_to_path2(struct mg_connection *c, struct mg_http_message *hm, (mg_snprintf(path + n, path_size - n, "/index.shtml") > 0 && (tmp = fs->st(path, NULL, NULL)) != 0))) { flags = tmp; + } else if ((mg_snprintf(path + n, path_size - n, "/" MG_HTTP_INDEX ".gz") > 0 && + (tmp = fs->st(path, NULL, NULL)) != 0)) { // check for gzipped index + flags = tmp; + path[n + 1 + strlen(MG_HTTP_INDEX)] = '\0'; // Remove appended .gz in index file name } else { path[n] = '\0'; // Remove appended index file name }