Set the default mime type. It can be helpful for a static HTTP site so
page names like site.com/page work rather than site.com/page.html

Of course, any static material must now be explicitly whitelisted as
application/octet-stream, so there is a trade-off when doing it this
way.
---
 config.def.h | 2 ++
 http.c       | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/config.def.h b/config.def.h
index 56f62aa..989f718 100644
--- a/config.def.h
+++ b/config.def.h
@@ -3,6 +3,7 @@

 #define BUFFER_SIZE 4096
 #define FIELD_MAX   200
+#define DEFAULT_MIME_TYPE "application/octet-stream"

 /* mime-types */
 static const struct {
@@ -37,3 +38,4 @@ static const struct {
 };

 #endif /* CONFIG_H */
+
diff --git a/http.c b/http.c
index 36f8b1c..af67b82 100644
--- a/http.c
+++ b/http.c
@@ -959,7 +959,7 @@ http_prepare_response(const struct request *req, struct 
response *res,
        }

        /* mime */
-       mime = "application/octet-stream";
+       mime = DEFAULT_MIME_TYPE;
        if ((p = strrchr(res->internal_path, '.'))) {
                for (i = 0; i < LEN(mimes); i++) {
                        if (!strcmp(mimes[i].ext, p + 1)) {
@@ -1044,3 +1044,4 @@ http_prepare_error_response(const struct request *req,
                }
        }
 }
+
-- 
2.39.3

Attachment: signature.asc
Description: PGP signature

Reply via email to