From: Ryan Bloom Date: Wed, 22 Nov 2000 19:38:07 +0000 (+0000) Subject: Allow modules to specify the first module for a sub-request. This allows X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=423c8a6a0f627ef5270c3748554d6fdb869b1f73;p=apache Allow modules to specify the first module for a sub-request. This allows modules to not have to muck with the output_filter after it creates the sub-request. Without this change, modules that create a sub-request have to manually edit the output_filters, and therefore skip the sub-request output_filter. If they skip the sub-request output_filter, then we end up sending multiple EOS buckets to the core_output_filter. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87065 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/http_request.h b/include/http_request.h index b1402b346c..fb81011718 100644 --- a/include/http_request.h +++ b/include/http_request.h @@ -95,33 +95,43 @@ extern "C" { * inspected to find information about the requested URI * @param new_file The URI to lookup * @param r The current request + * @param next_filter The first filter the sub_request should use. If this is + * NULL, it defaults to the first filter for the main request * @return The new request record * @deffunc request_rec * ap_sub_req_lookup_uri(const char *new_file, const request_rec *r) */ AP_DECLARE(request_rec *) ap_sub_req_lookup_uri(const char *new_file, - const request_rec *r); + const request_rec *r, + ap_filter_t *next_filter); + /** * Create a sub request for the given file. This sub request can be * inspected to find information about the requested file * @param new_file The URI to lookup * @param r The current request + * @param next_filter The first filter the sub_request should use. If this is + * NULL, it defaults to the first filter for the main request * @return The new request record * @deffunc request_rec * ap_sub_req_lookup_file(const char *new_file, const request_rec *r) */ AP_DECLARE(request_rec *) ap_sub_req_lookup_file(const char *new_file, - const request_rec *r); + const request_rec *r, + ap_filter_t *next_filter); /** * Create a sub request for the given URI using a specific method. This * sub request can be inspected to find information about the requested URI * @param method The method to use in the new sub request * @param new_file The URI to lookup * @param r The current request + * @param next_filter The first filter the sub_request should use. If this is + * NULL, it defaults to the first filter for the main request * @return The new request record * @deffunc request_rec * ap_sub_req_method_uri(const char *method, const char *new_file, const request_rec *r) */ AP_DECLARE(request_rec *) ap_sub_req_method_uri(const char *method, const char *new_file, - const request_rec *r); + const request_rec *r, + ap_filter_t *next_filter); /** * 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. diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c index ed44bdbaab..e0afbc4f8f 100644 --- a/modules/generators/mod_autoindex.c +++ b/modules/generators/mod_autoindex.c @@ -974,7 +974,7 @@ static void emit_head(request_rec *r, char *header_fname, int suppress_amble, * pretend there's nothing there. */ if ((header_fname != NULL) - && (rr = ap_sub_req_lookup_uri(header_fname, r)) + && (rr = ap_sub_req_lookup_uri(header_fname, r, NULL)) && (rr->status == HTTP_OK) && (rr->filename != NULL) && rr->finfo.filetype == APR_REG) { @@ -1057,7 +1057,7 @@ static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble) * pretend there's nothing there. */ if ((readme_fname != NULL) - && (rr = ap_sub_req_lookup_uri(readme_fname, r)) + && (rr = ap_sub_req_lookup_uri(readme_fname, r, NULL)) && (rr->status == HTTP_OK) && (rr->filename != NULL) && rr->finfo.filetype == APR_REG) { @@ -1184,7 +1184,7 @@ static struct ent *make_autoindex_entry(char *name, int autoindex_opts, p->version_sort = autoindex_opts & VERSION_SORT; if (autoindex_opts & FANCY_INDEXING) { - request_rec *rr = ap_sub_req_lookup_file(name, r); + request_rec *rr = ap_sub_req_lookup_file(name, r, NULL); if (rr->finfo.protection != 0) { p->lm = rr->finfo.mtime; diff --git a/modules/http/http_core.c b/modules/http/http_core.c index a9dfd1faf2..f6c7e99c19 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -3009,7 +3009,7 @@ static int default_handler(request_rec *r) ap_set_last_modified(r); ap_set_etag(r); apr_table_setn(r->headers_out, "Accept-Ranges", "bytes"); - ap_set_content_length(r, r->finfo.size); + ap_set_content_length(r, r->finfo.size); if ((errstatus = ap_meets_conditions(r)) != OK) { apr_close(fd); return errstatus; diff --git a/modules/http/http_request.c b/modules/http/http_request.c index 17bdf53838..3da29e49ea 100644 --- a/modules/http/http_request.c +++ b/modules/http/http_request.c @@ -806,7 +806,8 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_sub_req_output_filter(ap_filter_t *f, AP_DECLARE(request_rec *) ap_sub_req_method_uri(const char *method, const char *new_file, - const request_rec *r) + const request_rec *r, + ap_filter_t *next_filter) { request_rec *rnew; int res; @@ -830,7 +831,12 @@ AP_DECLARE(request_rec *) ap_sub_req_method_uri(const char *method, ap_copy_method_list(rnew->allowed_methods, r->allowed_methods); /* start with the same set of output filters */ - rnew->output_filters = r->output_filters; + if (next_filter) { + rnew->output_filters = next_filter; + } + else { + rnew->output_filters = r->output_filters; + } ap_add_output_filter("SUBREQ_CORE", NULL, rnew, rnew->connection); /* no input filters for a subrequest */ @@ -902,13 +908,15 @@ AP_DECLARE(request_rec *) ap_sub_req_method_uri(const char *method, } AP_DECLARE(request_rec *) ap_sub_req_lookup_uri(const char *new_file, - const request_rec *r) + const request_rec *r, + ap_filter_t *next_filter) { - return ap_sub_req_method_uri("GET", new_file, r); + return ap_sub_req_method_uri("GET", new_file, r, next_filter); } AP_DECLARE(request_rec *) ap_sub_req_lookup_file(const char *new_file, - const request_rec *r) + const request_rec *r, + ap_filter_t *next_filter) { request_rec *rnew; int res; @@ -932,7 +940,12 @@ AP_DECLARE(request_rec *) ap_sub_req_lookup_file(const char *new_file, ap_copy_method_list(rnew->allowed_methods, r->allowed_methods); /* start with the same set of output filters */ - rnew->output_filters = r->output_filters; + if (next_filter) { + rnew->output_filters = next_filter; + } + else { + rnew->output_filters = r->output_filters; + } ap_add_output_filter("SUBREQ_CORE", NULL, rnew, rnew->connection); /* no input filters for a subrequest */ diff --git a/modules/mappers/mod_dir.c b/modules/mappers/mod_dir.c index 16926e3950..76ccdc3ea9 100644 --- a/modules/mappers/mod_dir.c +++ b/modules/mappers/mod_dir.c @@ -161,7 +161,7 @@ static int handle_dir(request_rec *r) for (; num_names; ++names_ptr, --num_names) { char *name_ptr = *names_ptr; - request_rec *rr = ap_sub_req_lookup_uri(name_ptr, r); + request_rec *rr = ap_sub_req_lookup_uri(name_ptr, r, r->output_filters); if (rr->status == HTTP_OK && rr->finfo.filetype == APR_REG) { char *new_uri = ap_escape_uri(r->pool, rr->uri); diff --git a/modules/mappers/mod_negotiation.c b/modules/mappers/mod_negotiation.c index 02c2c12e01..c8919fcbb6 100644 --- a/modules/mappers/mod_negotiation.c +++ b/modules/mappers/mod_negotiation.c @@ -949,7 +949,7 @@ static int read_types_multi(negotiation_state *neg) * which we'll be slapping default_type on later). */ - sub_req = ap_sub_req_lookup_file(d_name, r); + sub_req = ap_sub_req_lookup_file(d_name, r, NULL); /* If it has a handler, we'll pretend it's a CGI script, * since that's a good indication of the sort of thing it @@ -2314,7 +2314,7 @@ static int setup_choice_response(request_rec *r, negotiation_state *neg, if (!variant->sub_req) { int status; - sub_req = ap_sub_req_lookup_file(variant->file_name, r); + sub_req = ap_sub_req_lookup_file(variant->file_name, r, NULL); status = sub_req->status; if (status != HTTP_OK && @@ -2625,7 +2625,7 @@ static int handle_multi(request_rec *r) * a sub_req structure yet. Get one now. */ - sub_req = ap_sub_req_lookup_file(best->file_name, r); + sub_req = ap_sub_req_lookup_file(best->file_name, r, NULL); if (sub_req->status != HTTP_OK) { res = sub_req->status; ap_destroy_sub_req(sub_req); diff --git a/server/util_script.c b/server/util_script.c index 2c03feb72b..786a005cc5 100644 --- a/server/util_script.c +++ b/server/util_script.c @@ -351,7 +351,8 @@ AP_DECLARE(void) ap_add_cgi_vars(request_rec *r) */ request_rec *pa_req; - pa_req = ap_sub_req_lookup_uri(ap_escape_uri(r->pool, r->path_info), r); + pa_req = ap_sub_req_lookup_uri(ap_escape_uri(r->pool, r->path_info), r, + NULL); if (pa_req->filename) { #ifdef WIN32