Sun, 12 Mar 2023 11:42:17 +0100
add force-type SAF
--- a/src/server/daemon/ws-fn.c Sun Mar 12 11:29:02 2023 +0100 +++ b/src/server/daemon/ws-fn.c Sun Mar 12 11:42:17 2023 +0100 @@ -51,6 +51,7 @@ { "redirect", redirect, NULL, NULL, 0}, { "simple-rewrite", simple_rewrite, NULL, NULL, 0}, { "type-by-extension", object_type_by_extension, NULL, NULL, 0}, + { "force-type", object_type_force_type, NULL, NULL, 0}, { "send-file", send_file, NULL, NULL, 0}, { "common-index", service_index, NULL, NULL, 0}, { "service-hello", service_hello, NULL, NULL, 0},
--- a/src/server/safs/objecttype.c Sun Mar 12 11:29:02 2023 +0100 +++ b/src/server/safs/objecttype.c Sun Mar 12 11:42:17 2023 +0100 @@ -79,3 +79,20 @@ pblock_kvinsert(pb_key_content_type, ct.ptr, ct.length, rq->srvhdrs); return REQ_PROCEED; } + +int object_type_force_type(pblock *pb, Session *sn, Request *rq) { + char *type = pblock_findkeyval(pb_key_type, pb); + + if(!type) { + return REQ_NOACTION; + } + + char *ct = pblock_findkeyval(pb_key_content_type, rq->srvhdrs); + if(ct) { + return REQ_NOACTION; + } + + pblock_kvinsert(pb_key_content_type, type, strlen(type), rq->srvhdrs); + + return REQ_PROCEED; +}
--- a/src/server/safs/objecttype.h Sun Mar 12 11:29:02 2023 +0100 +++ b/src/server/safs/objecttype.h Sun Mar 12 11:42:17 2023 +0100 @@ -39,6 +39,8 @@ int object_type_by_extension(pblock *pb, Session *sn, Request *rq); +int object_type_force_type(pblock *pb, Session *sn, Request *rq); + #ifdef __cplusplus } #endif