httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <...@covalent.net>
Subject Re: cvs commit: httpd-2.0/modules/http http_request.c
Date Fri, 01 Jun 2001 17:57:02 GMT


>   +static void add_required_filters(request_rec *r)
>   +{
>   +    ap_filter_t *f = r->output_filters;
>   +    int has_core = 0, has_content = 0, has_http_header = 0;
>   +    while (f) {
>   +        if(!strcasecmp(f->frec->name, "CORE"))
>   +            has_core = 1;
>   +        else if(!strcasecmp(f->frec->name, "CONTENT_LENGTH"))
>   +            has_content = 1;
>   +        else if(!strcasecmp(f->frec->name, "HTTP_HEADER"))
>   +            has_http_header = 1;
>   +        f = f->next;
>   +    }
>   +    if(!has_core)
>   +        ap_add_output_filter("CORE", NULL, r, r->connection);
>   +    if(!has_content)
>   +        ap_add_output_filter("CONTENT_LENGTH", NULL, r, r->connection);
>   +    if(!has_http_header)
>   +        ap_add_output_filter("HTTP_HEADER", NULL, r, r->connection);
>   +
>   +}
>   +
>    /*****************************************************************
>     *
>     * Mainline request processing...
>   @@ -201,6 +223,7 @@
>                            custom_response);
>            }
>        }
>   +    add_required_filters(r);
>        ap_send_error_response(r, recursive_error);
>    }

This could be made MUCH simpler by just changing reset_filters to:

void reset_filters(r)
{
    ap_filter_t *f = r->output_filters;
    int has_core = 0, has_content = 0, has_http_header = 0;
    while (f) {
	ap_filter_t *f2 = f->next;
	ap_remove_filter(f);
	f = f2;
    }
    ap_add_output_filter("CORE", NULL, r, r->connection);
    ap_add_output_filter("CONTENT_LENGTH", NULL, r, r->connection);
    ap_add_output_filter("HTTP_HEADER", NULL, r, r->connection);
}

This is slightly slower, but much easier to read and debug.  And, this is
an error condition, so who cares if we do three extra pointer
manipulations?

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------



Mime
View raw message