1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

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.
This commit is contained in:
Karl Rupp 2020-03-23 11:26:23 +01:00 committed by Andy Green
parent f684daefda
commit 6440521992

View file

@ -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);