From: Clinton Ebadi Date: Sun, 6 Jan 2019 02:57:09 +0000 (-0500) Subject: apache: support SetEnvIf X-Git-Tag: release_20190105-5 X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/commitdiff_plain/42233a46d8dc0f73d176726d9af605e69035a96c apache: support SetEnvIf Trivial SetEnvIf implementation. Attribute is a regex as that is the maximal syntax accepted for the argument, and the env arguments are just a list of no_spaces. This may change to something more like rewriteRule flags, with additional syntax for each case supported by apache (ENV, !ENV, ENV=VAL), and stricter syntax checking for the arguments. --- diff --git a/lib/mod_setenvif.dtl b/lib/mod_setenvif.dtl new file mode 100644 index 0000000..9056408 --- /dev/null +++ b/lib/mod_setenvif.dtl @@ -0,0 +1,6 @@ +{{Set internal environment variables using regexeps. mod_setenvif.}} + +extern val setEnvIf : regexp -> regexp -> [no_spaces] -> [^Vhost]; +{{Apache documentation for SetEnvIf}} +extern val setEnvIfNoCase : regexp -> regexp -> [no_spaces] -> [^Vhost]; +{{Apache documentation for SetEnvIfNoCase}} \ No newline at end of file diff --git a/src/plugins/apache.sml b/src/plugins/apache.sml index 3a446f6..a57ca9e 100644 --- a/src/plugins/apache.sml +++ b/src/plugins/apache.sml @@ -1147,6 +1147,34 @@ val () = Env.action_two "setEnv" | ch => str ch) value); write "\"\n")) +val () = Env.action_three "setEnvIf" + ("attribute", Env.string, "match", Env.string, "env_variables", Env.list Env.string) + (fn (attribute, match, envs) => + case envs of + [] => (print "WARNING: Skipped setEnvIf, no environment variables provided.\n") + | envs => + (write "\tSetEnvIf\t\""; + write attribute; + write "\"\t\""; + write match; + write "\""; + app (fn env => (write "\t"; write env)) envs; + write "\n")) + +val () = Env.action_three "setEnvIfNoCase" + ("attribute", Env.string, "match", Env.string, "env_variables", Env.list Env.string) + (fn (attribute, match, envs) => + case envs of + [] => (print "WARNING: Skipped setEnvIfNoCase, no environment variables provided.\n") + | envs => + (write "\tSetEnvIf\t\""; + write attribute; + write "\"\t\""; + write match; + write "\""; + app (fn env => (write "\t"; write env)) envs; + write "\n")) + val () = Env.action_one "diskCache" ("path", Env.string) (fn path => (write "\tCacheEnable disk \"";