From 5516fe8910c2ba90dbfbe8d89240e3df6b97ec85 Mon Sep 17 00:00:00 2001 From: Micah Moore Date: Wed, 7 Dec 2022 20:20:33 -0500 Subject: [PATCH] html5 fallback --- src/http.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/http.c b/src/http.c index b73967f..4e94027 100644 --- a/src/http.c +++ b/src/http.c @@ -312,8 +312,15 @@ handle_static_asset(struct http_transaction *ta, char *basedir) if (access(fname, R_OK)) { if (errno == EACCES) return send_error(ta, HTTP_PERMISSION_DENIED, "Permission denied."); - else - return send_not_found(ta); + else { + if (html5_fallback) { + memset(fname, 0, PATH_MAX); + snprintf(fname, sizeof fname, "%s%s", server_root, "/index.html"); + } else { + return send_not_found(ta); + } + } + } // Determine file size