allow to define a default mime-type to use when lookup in the internal table fails

instead of always returning 'text/plain'

To allow setting a different default mime-type the mg_get_mime_type() api has been
extended to require an mg_server parameter.

Note that using a static global as default mime type wouldn't have allowed us to
control it via a configuration option because there is not global initialization phase
and configuration options are provided (and specific) to each server instance.
This means that different servers can be configured to use a different default mime-type
(which is also a desired behaviour in many scenarios) when lookup fails.
This commit is contained in:
Andrea Guzzo committed 2014-01-24 14:45:19 +01:00
1 parent 2392156fd4
commit 45f6612096
2 files changed
+6 -4

No files matched your search

+1 -1
View File
@@ -86,7 +86,7 @@ int mg_printf(struct mg_connection *conn, const char *fmt, ...);
const char *mg_get_header(const struct mg_connection *, const char *name);
const char *mg_get_mime_type(const char *file_name);
const char *mg_get_mime_type(struct mg_server*, const char *file_name);
int mg_get_var(const struct mg_connection *conn, const char *var_name,
char *buf, size_t buf_len);
int mg_parse_header(const char *hdr, const char *var_name, char *buf, size_t);