Commit 423c8a6a authored by Ryan Bloom's avatar Ryan Bloom
Browse files

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
parent f1acc3d9
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -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.
+3 −3
Original line number Diff line number Diff line
@@ -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;
+19 −6
Original line number Diff line number Diff line
@@ -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 */
    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 */
    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 */
+1 −1
Original line number Diff line number Diff line
@@ -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);
+3 −3
Original line number Diff line number Diff line
@@ -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);
Loading