diff -r d07810b02147 -r de4bc3cd2d36 src/server/safs/objecttype.c --- a/src/server/safs/objecttype.c Sat Dec 29 18:08:23 2012 +0100 +++ b/src/server/safs/objecttype.c Sun Dec 30 15:49:44 2012 +0100 @@ -30,6 +30,9 @@ #include "../util/pblock.h" #include "../ucx/string.h" +#include "../ucx/map.h" +#include "../daemon/config.h" +#include "../daemon/session.h" int object_type_by_extension(pblock *pb, Session *sn, Request *rq) { sstr_t ppath = sstr(pblock_findkeyval(pb_key_ppath, rq->vars)); @@ -55,18 +58,16 @@ return REQ_NOACTION; } - /* TODO: we need a map for extensions/types */ - if(!sstrcmp(ext, sstrn("txt", 3))) { - ct = sstr("text/plain"); - } else if(!sstrcmp(ext, sstrn("htm", 3))) { - ct = sstr("text/html"); - } else if(!sstrcmp(ext, sstrn("html", 4))) { - ct = sstr("text/html"); - } else if(!sstrcmp(ext, sstrn("xml", 3))) { - ct = sstr("text/xml"); - } else { + /* get the mime type for the ext from the server configuration */ + ServerConfiguration *config = session_get_config(sn); + char *type = ucx_map_sstr_get(config->mimetypes, ext); + + if(!type) { return REQ_NOACTION; } + + ct.ptr = type; + ct.length = strlen(type); } pblock_kvinsert(pb_key_content_type, ct.ptr, ct.length, rq->srvhdrs);