From: Ryan Bloom Date: Sat, 21 Oct 2000 17:22:28 +0000 (+0000) Subject: Add a way to remove output filters. This is used by http_header_filter to X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=972b5a5e156822fda64a6b4d96c6a9e560c1b65c;p=apache Add a way to remove output filters. This is used by http_header_filter to remove itself once it has actually sent the headers. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86690 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/util_filter.h b/include/util_filter.h index edcc4eb636..7c6489559d 100644 --- a/include/util_filter.h +++ b/include/util_filter.h @@ -360,6 +360,8 @@ AP_DECLARE(void) ap_add_input_filter(const char *name, void *ctx, request_rec *r AP_DECLARE(void) ap_add_output_filter(const char *name, void *ctx, request_rec *r, conn_rec *c); +AP_DECLARE(void) ap_remove_output_filter(ap_filter_t *f); + /* The next two filters are for abstraction purposes only. They could be * done away with, but that would require that we break modules if we ever * want to change our filter registration method. The basic idea, is that diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 0a1f0ee770..e2dfc84bd7 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -2228,11 +2228,6 @@ AP_CORE_DECLARE(int) ap_http_header_filter(ap_filter_t *f, ap_bucket_brigade *b) char *date = NULL; request_rec *r = f->r; - if ((int)f->ctx != 0) { - return ap_pass_brigade(f->next, b); - } - (int)f->ctx++; - if (r->assbackwards) { if (!r->main) ap_bsetopt(r->connection->client, BO_BYTECT, &zero); @@ -2325,6 +2320,7 @@ AP_CORE_DECLARE(int) ap_http_header_filter(ap_filter_t *f, ap_bucket_brigade *b) if (r->chunked) { ap_bsetflag(r->connection->client, B_CHUNK, 1); } + ap_remove_output_filter(f); return ap_pass_brigade(f->next, b); } diff --git a/server/util_filter.c b/server/util_filter.c index 85780a04f6..dcd7c06a29 100644 --- a/server/util_filter.c +++ b/server/util_filter.c @@ -155,6 +155,31 @@ AP_DECLARE(void) ap_add_input_filter(const char *name, void *ctx, } } +AP_DECLARE(void) ap_remove_output_filter(ap_filter_t *f) +{ + ap_filter_t *curr; + + curr = f->r ? f->r->output_filters : f->c->output_filters; + + if (curr == f) { + if (f->r) { + f->r->output_filters = f->r->output_filters->next; + } + else { + f->c->output_filters = f->c->output_filters->next; + } + return; + } + + while (curr->next != f) { + if (curr == NULL) { + return; + } + curr = curr->next; + } + curr->next = f->next ? f->next : NULL; +} + AP_DECLARE(void) ap_add_output_filter(const char *name, void *ctx, request_rec *r, conn_rec *c) {