From bb439e766a759cf632e9149cb637157413569dbd Mon Sep 17 00:00:00 2001 From: Karl Rupp Date: Mon, 23 Mar 2020 21:03:54 +0000 Subject: [PATCH] http server: Using default filename also for subdirectories. If a user sets a default filename for a http mount (.def in lws_http_mount), eg. 'default.html', then a GET request for '/' correctly forwards to '/default.html'. However, without this commit the default filename is not taken into account for subdirectories. Thus, GET subdir/ will forward to 'subdir/index.html' instead of the expected 'subdir/default.html' This commit changes the behavior such that the user-provided default filename is also used for subdirectories. --- lib/roles/http/server/server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c index e6205c9cb..0baba256f 100644 --- a/lib/roles/http/server/server.c +++ b/lib/roles/http/server/server.c @@ -587,8 +587,8 @@ lws_http_serve(struct lws *wsi, char *uri, const char *origin, #endif if ((S_IFMT & st.st_mode) == S_IFDIR) { lwsl_debug("default filename append to dir\n"); - lws_snprintf(path, sizeof(path) - 1, "%s/%s/index.html", - origin, uri); + lws_snprintf(path, sizeof(path) - 1, "%s/%s/%s", + origin, uri, m->def ? m->def : "index.html"); } } while ((S_IFMT & st.st_mode) != S_IFREG && spin < 5);