You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by dg...@hyperreal.org on 1999/12/31 06:35:54 UTC
cvs commit: apache-1.3/src/modules/standard mod_autoindex.c mod_include.c
dgaudet 99/12/30 21:35:53
Modified: src CHANGES
src/modules/standard mod_autoindex.c mod_include.c
Log:
> Attached are 2 alternative diffs to finish implementing server-parsed
> mod_autoindex Header and Readme files in apache_1.3. A third diff is
> attached that shows the differences between the alternatives.
>
> Why this is needed: With an unpatched apache_1.3.9, the include variables
> DOCUMENT_NAME, DOCUMENT_PATH_INFO, DOCUMENT_URI, LAST_MODIFIED,
> SCRIPT_NAME, and SERVER_PROTOCOL will have values reflecting the Header
> or Readme files instead of the directory. Contrast this with the use of
> included files in a non directory document where those include variables
> reflect the base document, not the included file.
>
> Both alternatives work with and without various pool/memory
> allocation/deallocation debugging options enabled and using various
> compiler optimization levels on Linux. Alternative 0 has been in use for
> the last 6 months (without the ap_table_unset's in mod_autoindex) using
> apache_1.3.7-dev (downloaded 19990504) without problems.
>
> Two alternatives are presented because Dean did not think that alternative
> 0 was safe 6 months ago. I believe that it is and it provides a cleaner
> method for module authors to use the power and flexibility of mod_include
> to enhance generated content, like mod_autoindex.
i chose alternative 0.
Submitted by: Raymond S Brand <rs...@rsbx.net>
Revision Changes Path
1.1487 +3 -0 apache-1.3/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.1486
retrieving revision 1.1487
diff -u -r1.1486 -r1.1487
--- CHANGES 1999/12/28 09:12:33 1.1486
+++ CHANGES 1999/12/31 05:35:48 1.1487
@@ -1,5 +1,8 @@
Changes with Apache 1.3.10
+ *) Changes to enable server-parsed mod_autoindex Header and
+ Readme files. [Raymond S Brand <rs...@rsbx.net>]
+
*) Add back support for UseCanonicalName in <Directory> containers
[Manoj Kasichainula]
1.113 +16 -0 apache-1.3/src/modules/standard/mod_autoindex.c
Index: mod_autoindex.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_autoindex.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -r1.112 -r1.113
--- mod_autoindex.c 1999/12/01 22:10:45 1.112
+++ mod_autoindex.c 1999/12/31 05:35:52 1.113
@@ -970,6 +970,10 @@
ap_rputs("</PRE>\n", r);
}
+/* See mod_include */
+#define SUB_REQ_STRING "Sub request to mod_include"
+#define PARENT_STRING "Parent request to mod_include"
+
/*
* Handle the preamble through the H1 tag line, inclusive. Locate
* the file with a subrequests. Process text/html documents by actually
@@ -1012,6 +1016,11 @@
if (! suppress_amble) {
emit_preamble(r, title);
}
+
+ /* See mod_include */
+ ap_table_add(r->notes, PARENT_STRING, "");
+ ap_table_add(rr->notes, SUB_REQ_STRING, "");
+
/*
* If there's a problem running the subrequest, display the
* preamble if we didn't do it before -- the header file
@@ -1022,6 +1031,7 @@
emit_amble = suppress_amble;
emit_H1 = 1;
}
+ ap_table_unset(r->notes, PARENT_STRING); /* cleanup */
}
else if (!strncasecmp("text/", rr->content_type, 5)) {
/*
@@ -1087,11 +1097,17 @@
if (rr->content_type != NULL) {
if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type),
"text/html")) {
+
+ /* See mod_include */
+ ap_table_add(r->notes, PARENT_STRING, "");
+ ap_table_add(rr->notes, SUB_REQ_STRING, "");
+
if (ap_run_sub_req(rr) == OK) {
/* worked... */
suppress_sig = 1;
suppress_post = suppress_amble;
}
+ ap_table_unset(r->notes, PARENT_STRING); /* cleanup */
}
else if (!strncasecmp("text/", rr->content_type, 5)) {
/*
1.121 +58 -10 apache-1.3/src/modules/standard/mod_include.c
Index: mod_include.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_include.c,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -r1.120 -r1.121
--- mod_include.c 1999/12/11 00:36:17 1.120
+++ mod_include.c 1999/12/31 05:35:52 1.121
@@ -108,9 +108,6 @@
module MODULE_VAR_EXPORT includes_module;
-/* just need some arbitrary non-NULL pointer which can't also be a request_rec */
-#define NESTED_INCLUDE_MAGIC (&includes_module)
-
/* ------------------------ Environment function -------------------------- */
/* XXX: could use ap_table_overlap here */
@@ -745,10 +742,7 @@
ap_rputs(error, r);
}
- /* destroy the sub request if it's not a nested include */
- if (rr != NULL
- && ap_get_module_config(rr->request_config, &includes_module)
- != NESTED_INCLUDE_MAGIC) {
+ if (rr != NULL) {
ap_destroy_sub_req(rr);
}
}
@@ -2375,6 +2369,53 @@
return OK;
}
+#define SUB_REQ_STRING "Sub request to mod_include"
+#define PARENT_STRING "Parent request to mod_include"
+
+ if (ap_table_get(r->notes, SUB_REQ_STRING)) {
+ /*
+ * The note is a flag to mod_include that this request
+ * should be treated as if it was a subrequest originating
+ * in the handle_include() procedure of mod_include.
+ */
+
+ /*
+ * There is no good way to pass the parent request_rec to mod_include.
+ * Tables only take string values and there is nowhere appropriate in
+ * in the request_rec that can safely be used. So, search for the
+ * parent note by walking up the r->main list of subrequests, and at
+ * each level walking back through any internal redirects. This is
+ * the same request walking that mod_include uses in the procedure
+ * handle_include().
+ */
+ request_rec *p = r->main;
+ request_rec *q = p;
+
+ while (q) {
+ if (ap_table_get(q->notes, PARENT_STRING)) {
+ /* Kludge --- See below */
+ ap_set_module_config(r->request_config, &includes_module, q);
+
+ /* Create the initial environment in the parent */
+ ap_add_common_vars(q);
+ ap_add_cgi_vars(q);
+ add_include_vars(q, DEFAULT_TIME_FORMAT);
+
+ /* Cleanup - This should allow this technique to nest */
+ ap_table_unset(r->notes, SUB_REQ_STRING);
+ ap_table_unset(q->notes, PARENT_STRING);
+ break;
+ }
+ if (q->prev != NULL) {
+ q = q->prev;
+ }
+ else {
+ p = p->main;
+ q = p;
+ }
+ }
+ }
+
if ((parent = ap_get_module_config(r->request_config, &includes_module))) {
/* Kludge --- for nested includes, we want to keep the subprocess
* environment of the base document (for compatibility); that means
@@ -2410,9 +2451,16 @@
send_parsed_content(f, r);
if (parent) {
- /* signify that the sub request should not be killed */
- ap_set_module_config(r->request_config, &includes_module,
- NESTED_INCLUDE_MAGIC);
+ /*
+ * All the work is finished for this subrequest. The following
+ * makes it safe for the creator of the subrequest to destroy it
+ * via ap_destroy_sub_req() once the call to ap_run_sub_req()
+ * returns. This is required since the original pool of the
+ * subrequest has been merged into the pool of the parent request
+ * of the subrequest (see Kludge above). The alternative is to
+ * NOT destroy the subrequest.
+ */
+ r->pool = ap_make_sub_pool(r->pool);
}
ap_kill_timeout(r);