From 7f012ffdbae5dbee9642fee030647d558b25c8c4 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Mon, 7 Aug 2006 04:02:12 +0000 Subject: [PATCH] More Apache directory option stuff --- lib/apache_options.dtl | 13 +++++++++++++ src/main.sml | 1 + src/parse.sml | 2 +- src/plugins/apache.sml | 23 +++++++++++++++++++++++ tests/testApache.dtl | 10 +++++++++- 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/lib/apache_options.dtl b/lib/apache_options.dtl index c678d47..83f3465 100644 --- a/lib/apache_options.dtl +++ b/lib/apache_options.dtl @@ -18,3 +18,16 @@ extern val unset_options : [apache_option] -> [^Vhost]; extern val directoryIndex : [no_spaces] -> [^Vhost]; {{Give the list of filenames to try for the default page of a directory, to be considered in the order given.}} + +extern val forceType : no_spaces -> [Location]; +extern val forceTypeOff : [Location]; +{{Force all files in the current directory to be served with the given MIME + type.}} + +extern val action : no_spaces -> location -> [^Vhost]; +{{See the + Apache documentation.}} + +extern val addDefaultCharset : no_spaces -> [^Vhost]; +{{See the + Apache documentation.}} diff --git a/src/main.sml b/src/main.sml index 22577ad..705b20a 100644 --- a/src/main.sml +++ b/src/main.sml @@ -89,6 +89,7 @@ fun check fname = (b, NONE) else let + val _ = ErrorMsg.reset () val prog = Parse.parse fname in if !ErrorMsg.anyErrors then diff --git a/src/parse.sml b/src/parse.sml index 90cf07c..00fefca 100644 --- a/src/parse.sml +++ b/src/parse.sml @@ -29,7 +29,7 @@ structure Parse :> PARSE = (* The main parsing routine *) fun parse filename = - let val _ = ErrorMsg.fileName := filename + let val _ = (ErrorMsg.fileName := filename) val file = TextIO.openIn filename fun get _ = TextIO.input file fun parseerror(s,p1,p2) = ErrorMsg.error (SOME (p1,p2)) s diff --git a/src/plugins/apache.sml b/src/plugins/apache.sml index 7689860..23f8dd3 100644 --- a/src/plugins/apache.sml +++ b/src/plugins/apache.sml @@ -460,4 +460,27 @@ val () = Env.action_none "satisfyAll" val () = Env.action_none "satisfyAny" (fn () => write "\tSatisfy any\n") +val () = Env.action_one "forceType" + ("type", Env.string) + (fn ty => (write "\tForceType "; + write ty; + write "\n")) + +val () = Env.action_none "forceTypeOff" + (fn () => write "\tForceType None\n") + +val () = Env.action_two "action" + ("what", Env.string, "how", Env.string) + (fn (what, how) => (write "\tAction "; + write what; + write " "; + write how; + write "\n")) + +val () = Env.action_one "addDefaultCharset" + ("charset", Env.string) + (fn ty => (write "\tAddDefaultCharset "; + write ty; + write "\n")) + end diff --git a/tests/testApache.dtl b/tests/testApache.dtl index acade80..e637d69 100644 --- a/tests/testApache.dtl +++ b/tests/testApache.dtl @@ -6,7 +6,7 @@ domain "hcoop.net" with DocumentRoot = "/home/adamc/html"; ServerAdmin = "adamc@hcoop.net" with - + addDefaultCharset "mumbo-jumbo/incomprehensible" end; vhost "members" where @@ -33,6 +33,8 @@ domain "hcoop.net" with scriptAlias "/cgi-bin/that-script" "/home/adamc/cgi/here-it-is"; errorDocument "404" "I just couldn't find it."; + action "text/plain" "/cgi-bin/display"; + directory "/home/adamc/thisPlace" with rewriteRule "A" "B" []; unset_options [includesNOEXEC]; @@ -43,6 +45,10 @@ domain "hcoop.net" with proxyPass "/mailman" "http://hcoop.net/cgi-bin/mailman"; alias "/doc/mailman" "/home/adamc/mailman"; + location "/the-citadel" with + forceTypeOff; + end; + directoryIndex ["index.sml", "index.h", "index.v"] end; @@ -56,6 +62,8 @@ domain "hcoop.net" with requireUser ["freddy", "flicky"]; requireGroup ["awesome"]; + forceType "text/html"; + orderDenyAllow; satisfyAny end -- 2.20.1