add force-type SAF

Sun, 12 Mar 2023 11:42:17 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 12 Mar 2023 11:42:17 +0100
changeset 466
019c22775f7c
parent 465
d22ff46c171c
child 467
4d038bc6f86e

add force-type SAF

src/server/daemon/ws-fn.c file | annotate | diff | comparison | revisions
src/server/safs/objecttype.c file | annotate | diff | comparison | revisions
src/server/safs/objecttype.h file | annotate | diff | comparison | revisions
--- 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

mercurial