Skip to content

Commit

Permalink
http server: Using default filename also for subdirectories.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
karlrupp authored and lws-team committed Mar 23, 2020
1 parent f684dae commit 6440521
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/roles/http/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6440521

Please sign in to comment.