shithub: werc

Download patch

ref: c1bfeb119c8ff5dc8496e928955066d68e7b6252
parent: 6fdcbd3ab200b937449e2781e27077a1a3ae5720
author: uriel <[email protected]>
date: Sat Jan 10 00:23:44 EST 2009

Handle static files! (Should only be used as a fallback if static files are not handled by httpd)

--- a/bin/werc.rc
+++ b/bin/werc.rc
@@ -116,6 +116,28 @@
     if not if(~ $local_path *.html && test -f $local_path)
         perm_redirect `{ echo $req_path|sed 's/.html$//' }
 
+    # Fallback static file handler
+    if not if(test -f $local_path) {
+        m='text/plain'
+        if(~ $req_path *.css)
+            m='text/css'
+        if not if(~ $req_path *.ico)
+            m='image/x-icon'
+        if not if(~ $req_path *.png)
+            m='image/png'
+        if not if(~ $req_path *.jpg *.jpeg)
+            m='image/jpeg'
+        if not if(~ $req_path *.gif)
+            m='image/gif'
+        if not if(~ $req_path *.pdf)
+            m='application/pdf'
+
+        echo 'Content-Type: '^$m
+        echo
+        cat $local_path
+        exit
+    }
+
     # File not found
     if not {
         set_handler tpl_handler `{get_lib_file 404.tpl}