Commit 511ef413 authored by Sergey Lyubka's avatar Sergey Lyubka

Better SSI mime type handling

parent 47916412
...@@ -3788,6 +3788,7 @@ static void send_ssi_file(struct mg_connection *conn, const char *path, ...@@ -3788,6 +3788,7 @@ static void send_ssi_file(struct mg_connection *conn, const char *path,
static void handle_ssi_file_request(struct mg_connection *conn, static void handle_ssi_file_request(struct mg_connection *conn,
const char *path) { const char *path) {
struct file file = STRUCT_FILE_INITIALIZER; struct file file = STRUCT_FILE_INITIALIZER;
struct vec mime_vec;
if (!mg_fopen(conn, path, "rb", &file)) { if (!mg_fopen(conn, path, "rb", &file)) {
send_http_error(conn, 500, http_500_error, "fopen(%s): %s", path, send_http_error(conn, 500, http_500_error, "fopen(%s): %s", path,
...@@ -3795,9 +3796,11 @@ static void handle_ssi_file_request(struct mg_connection *conn, ...@@ -3795,9 +3796,11 @@ static void handle_ssi_file_request(struct mg_connection *conn,
} else { } else {
conn->must_close = 1; conn->must_close = 1;
fclose_on_exec(&file); fclose_on_exec(&file);
get_mime_type(conn->ctx, path, &mime_vec);
mg_printf(conn, "HTTP/1.1 200 OK\r\n" mg_printf(conn, "HTTP/1.1 200 OK\r\n"
"Content-Type: text/html\r\nConnection: %s\r\n\r\n", "Content-Type: %.*s\r\n"
suggest_connection_header(conn)); "Connection: close\r\n\r\n",
(int) mime_vec.len, mime_vec.ptr);
send_ssi_file(conn, path, &file, 0); send_ssi_file(conn, path, &file, 0);
mg_fclose(&file); mg_fclose(&file);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment