apache: support SetEnvIf release_20190105-5
authorClinton Ebadi <clinton@unknownlamer.org>
Sun, 6 Jan 2019 02:57:09 +0000 (21:57 -0500)
committerClinton Ebadi <clinton@unknownlamer.org>
Sun, 6 Jan 2019 02:57:09 +0000 (21:57 -0500)
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.

lib/mod_setenvif.dtl [new file with mode: 0644]
src/plugins/apache.sml

diff --git a/lib/mod_setenvif.dtl b/lib/mod_setenvif.dtl
new file mode 100644 (file)
index 0000000..9056408
--- /dev/null
@@ -0,0 +1,6 @@
+{{Set internal environment variables using regexeps. <a href="https://httpd.apache.org/docs/2.4/mod/mod_setenvif.html">mod_setenvif</a>.}}
+
+extern val setEnvIf : regexp -> regexp -> [no_spaces] -> [^Vhost];
+{{<a href="https://httpd.apache.org/docs/2.4/mod/mod_setenvif.html#setenvif">Apache documentation for <tt>SetEnvIf</tt></a>}}
+extern val setEnvIfNoCase : regexp -> regexp -> [no_spaces] -> [^Vhost];
+{{<a href="https://httpd.apache.org/docs/2.4/mod/mod_setenvifnocase.html#setenvif">Apache documentation for <tt>SetEnvIfNoCase</tt></a>}}
\ No newline at end of file
index 3a446f6..a57ca9e 100644 (file)
@@ -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 \"";