]> granicus.if.org Git - apache/commitdiff
Add a sub-request filter. This filter just strips the EOS from the
authorRyan Bloom <rbb@apache.org>
Mon, 16 Oct 2000 23:15:55 +0000 (23:15 +0000)
committerRyan Bloom <rbb@apache.org>
Mon, 16 Oct 2000 23:15:55 +0000 (23:15 +0000)
brigade generated by the sub-request.  If this is not done, then the
main-request's core_output_filter will get very confused, as will any other
filter in the main-request filter-stack that looks for EOS.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86618 13f79535-47bb-0310-9956-ffa450edef68

STATUS
include/http_request.h
modules/http/http_core.c
modules/http/http_protocol.c
modules/http/http_request.c

diff --git a/STATUS b/STATUS
index 64ed98b4dfa2936e64d2bbb743b8bcb9a1b0b46b..3864e0b625fdae2dcc00840a51cebdb227cdc06b 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -1,5 +1,5 @@
 Apache 2.0 STATUS:
-Last modified at [$Date: 2000/10/13 16:57:08 $]
+Last modified at [$Date: 2000/10/16 23:15:54 $]
 
 Release:
 
@@ -20,14 +20,8 @@ RELEASE SHOWSTOPPERS:
 
     * All of the bucket types must be implemented.  The list can be found
       in src/include/ap_buckets.h. May need to implement a bucket type
-      to mark the end of a subrequest content stream, and one to tell
-      filters to flush any pending content. See http_protocol.c:
-      ap_finalize_sub_req_protocol() and ap_rflush()
-       rbb says:  Creating a bucket to signal end of sub-request ties
-                  the filters to Apache.  This can be handled very cleanly
-                  by just inserting a sub-request filter.  That filter would
-                  be responsible for stripping off the EOS bucket for the
-                  sub-request, and removing all vestiges of the request.
+      to tell filters to flush any pending content. See http_protocol.c:
+      ap_rflush()
 
     * Remove Buff from the code.  Some buff functionality is currently 
       missing: input translation filter, translation of protocol data for 
index cf5e6f8ef1aec24482b6fd3ea91837ce8008df81..444eddca6148da5239512efb26cbe0e021d413af 100644 (file)
@@ -60,6 +60,7 @@
 #define APACHE_HTTP_REQUEST_H
 
 #include "ap_hooks.h"
+#include "util_filter.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -121,6 +122,15 @@ AP_DECLARE(request_rec *) ap_sub_req_lookup_file(const char *new_file,
 AP_DECLARE(request_rec *) ap_sub_req_method_uri(const char *method,
                                                 const char *new_file,
                                                 const request_rec *r);
+/**
+ * An output filter to strip EOS buckets from sub-requests.  This always
+ * has to be inserted at the end of a sub-requests filter stack.
+ * @param f The current filter
+ * @param bb The brigade to filter
+ * @deffuc apr_status_t ap_sub_req_output_filter(ap_filter_t *f, ap_bucket_brigade *bb)
+ */
+AP_CORE_DECLARE(apr_status_t) ap_sub_req_output_filter(ap_filter_t *f,
+                                                 ap_bucket_brigade *bb);
 
 /**
  * Run the handler for the sub request
index d43d44b33825498bb1a8e20e0e4caebcb5075ab9..c3b789bb0dfbc3e41bb86695f74edc75ee25fbd9 100644 (file)
@@ -3584,6 +3584,8 @@ static void register_hooks(void)
     ap_register_input_filter("DECHUNK", dechunk_filter, AP_FTYPE_CONNECTION + 1);
     ap_register_input_filter("CORE_IN", core_input_filter, AP_FTYPE_CONNECTION);
     ap_register_output_filter("CORE", core_output_filter, AP_FTYPE_CONNECTION + 1);
+    ap_register_output_filter("SUBREQ_CORE", ap_sub_req_output_filter, 
+                              AP_FTYPE_CONTENT);
     ap_register_output_filter("CHUNK", chunk_filter, AP_FTYPE_CONNECTION);
     ap_register_output_filter("BUFFER", buffer_filter, AP_FTYPE_CONNECTION);
 }
index d8b4b9d5cd78421df91512dd9474f618435eb77b..f93febd960eb4fa645465ce7d1e78b88dbbede3c 100644 (file)
@@ -1560,12 +1560,7 @@ static void end_output_stream(request_rec *r)
 
 void ap_finalize_sub_req_protocol(request_rec *sub)
 {
-    /* tell the filter chain there is no more content coming */
-    /* ### crap. we need to tell the subrequest's filters that no more
-       ### is coming. there is definitely more for the parent requests.
-       ### create a SUB_EOS bucket?
-    */
-    /* end_output_stream(sub); */
+    end_output_stream(sub); 
 
     SET_BYTES_SENT(sub->main);
 }
index 9b24bd7e84261402fd105c89c4107384430f51bd..cc97c33d38c0800d0c5cc719a92545cf9f016100 100644 (file)
@@ -817,6 +817,19 @@ static request_rec *make_sub_request(const request_rec *r)
     return rr;
 }
 
+AP_CORE_DECLARE(apr_status_t) ap_sub_req_output_filter(ap_filter_t *f,
+                                                 ap_bucket_brigade *bb)
+{
+    ap_bucket *e = AP_BRIGADE_LAST(bb);
+
+    if (AP_BUCKET_IS_EOS(e)) {
+        AP_BUCKET_REMOVE(e);
+        ap_bucket_destroy(e);
+    }
+    ap_pass_brigade(f->next, bb);
+    return APR_SUCCESS;
+}
+
 AP_DECLARE(request_rec *) ap_sub_req_method_uri(const char *method,
                                                 const char *new_file,
                                                 const request_rec *r)
@@ -840,6 +853,8 @@ AP_DECLARE(request_rec *) ap_sub_req_method_uri(const char *method,
 
     /* start with the same set of output filters */
     rnew->output_filters = r->output_filters;
+    ap_add_output_filter("SUBREQ_CORE", NULL, rnew, rnew->connection); 
+
     /* no input filters for a subrequest */
 
     ap_set_sub_req_protocol(rnew, r);
@@ -936,6 +951,8 @@ AP_DECLARE(request_rec *) ap_sub_req_lookup_file(const char *new_file,
 
     /* start with the same set of output filters */
     rnew->output_filters = r->output_filters;
+    ap_add_output_filter("SUBREQ_CORE", NULL, rnew, rnew->connection); 
+
     /* no input filters for a subrequest */
 
     ap_set_sub_req_protocol(rnew, r);