Index: mod_include.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/filters/mod_include.c,v
retrieving revision 1.109
diff -u -r1.109 mod_include.c
--- mod_include.c       2001/04/21 22:01:05     1.109
+++ mod_include.c       2001/05/02 03:42:05
@@ -98,6 +98,9 @@

 #define BYTE_COUNT_THRESHOLD AP_MIN_BYTES_TO_WRITE

+
+
+static void set_lazy_vars( request_rec *r ) ;
 /* ------------------------ Environment function -------------------------- */

 /* XXX: could use ap_table_overlap here */
@@ -637,6 +640,7 @@
                const char *expansion, *temp_end, *val;
                 char        tmp_store;
                size_t l;
+       set_lazy_vars(r);

                /* guess that the expansion won't happen */
                expansion = in - 1;
@@ -889,6 +893,9 @@
     encode = E_ENTITY;

     *inserted_head = NULL;
+
+    set_lazy_vars(r);
+
     if (ctx->flags & FLAG_PRINTING) {
         while (1) {
             ap_ssi_get_tag_and_value(ctx, &tag, &tag_val, 1);
@@ -2299,6 +2306,8 @@
     char *tag_val = NULL;
     apr_bucket *tmp_buck;

+    set_lazy_vars(r);
+
     if (ctx->flags & FLAG_PRINTING) {
         ap_ssi_get_tag_and_value(ctx, &tag, &tag_val, 1);
         if ((tag == NULL) && (tag_val == NULL)) {
@@ -2747,9 +2756,7 @@
     else {
        /* we're not a nested include, so we create an initial
         * environment */
-        ap_add_common_vars(r);
-        ap_add_cgi_vars(r);
-        add_include_vars(r, conf->default_time_fmt);
+        apr_table_unset( r->subprocess_env, "INCLUDE_VARS" );
     }
     /* XXX: this is bogus, at some point we're going to do a subrequest,
      * and when we do it we're going to be subjecting code that doesn't
@@ -2817,6 +2824,22 @@
     include_dir_config *conf = (include_dir_config *)mconfig;
     conf->default_time_fmt = apr_pstrdup(cmd->pool, fmt);
     return NULL;
+}
+/*
+ * Perform a evaluation of Standard SSI Include vars if they have not been included already
+ *
+ */
+static void set_lazy_vars( request_rec *r )
+{
+
+    if ( apr_table_get( r->subprocess_env, "INCLUDE_VARS" ) == NULL ) {
+         include_dir_config *conf = (include_dir_config *)ap_get_module_config(r->per_dir_config,
+                     &include_module);
+        apr_table_setn(r->subprocess_env, "INCLUDE_VARS", "Y");
+        ap_add_common_vars(r);
+        ap_add_cgi_vars(r);
+        add_include_vars(r, conf->default_time_fmt);
+    }
 }

 /*

