diff options
Diffstat (limited to 'plugins/static/static.c')
-rw-r--r-- | plugins/static/static.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/static/static.c b/plugins/static/static.c index 0b39afe..61cd259 100644 --- a/plugins/static/static.c +++ b/plugins/static/static.c @@ -9,6 +9,7 @@ #include "plugin.h" #include "util.h" #include "buffer.h" +#include "mime.h" // Will only be set once in the registration function, which is before any threading is done @@ -110,7 +111,10 @@ static Handler_ret_t connection_handler(int sock, Headers *headers) { } } - buffer = build_response_headers("200 OK", "text/plain; charset=UTF-8", size); + const char *mimetype = mime_detect(path); + if (!mimetype) mimetype = "application/octet-stream"; + + buffer = build_response_headers("200 OK", mimetype, size); if (!buffer_append_file(&buffer, path)) { send_500(sock); goto cleanup_return; @@ -131,5 +135,7 @@ void plugin_register_yourself(register_callback_t callback) { exit(1); } + mime_init(); + callback("static", &connection_handler); } |