From: Ryan Bloom Date: Mon, 16 Oct 2000 23:15:55 +0000 (+0000) Subject: Add a sub-request filter. This filter just strips the EOS from the X-Git-Tag: APACHE_2_0_ALPHA_8~346 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=25535f86eca48fe2e4c3ce27419ebea05b86a120;p=thirdparty%2Fapache%2Fhttpd.git Add a sub-request filter. This filter just strips the EOS from the 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 --- diff --git a/STATUS b/STATUS index 64ed98b4dfa..3864e0b625f 100644 --- 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 diff --git a/include/http_request.h b/include/http_request.h index cf5e6f8ef1a..444eddca614 100644 --- a/include/http_request.h +++ b/include/http_request.h @@ -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 diff --git a/modules/http/http_core.c b/modules/http/http_core.c index d43d44b3382..c3b789bb0df 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -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); } diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index d8b4b9d5cd7..f93febd960e 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -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); } diff --git a/modules/http/http_request.c b/modules/http/http_request.c index 9b24bd7e842..cc97c33d38c 100644 --- a/modules/http/http_request.c +++ b/modules/http/http_request.c @@ -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);