From: Ryan Bloom Date: Tue, 4 Jun 2002 18:50:13 +0000 (+0000) Subject: Allow ap_discard_request_body to be called multiple times in the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e68fc705833b5c3d5b129341247681b925579fa9;p=apache Allow ap_discard_request_body to be called multiple times in the same request. Essentially, ap_http_filter keeps track of whether it has sent an EOS bucket up the stack, if so, it will only ever send an EOS bucket for this request. Submitted by: Ryan Bloom, Justin Erenkrantz, Greg Stein git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95505 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index a1b35deb3d..959316aca5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,11 @@ Changes with Apache 2.0.37 + *) Allow ap_discard_request_body to be called multiple times in the + same request. Essentially, ap_http_filter keeps track of whether + it has sent an EOS bucket up the stack, if so, it will only ever + send an EOS bucket for this request. + [Ryan Bloom, Justin Erenkrantz, Greg Stein] + *) Remove all special mod_ssl URIs. This also fixes the bug where redirecting (.*) will allow an SSL protected page to be viewed without SSL. [Ryan Bloom] diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index b2dcfacd64..01c4510b1a 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -742,6 +742,7 @@ typedef struct http_filter_ctx { BODY_LENGTH, BODY_CHUNK } state; + int eos_sent; } http_ctx_t; /* This is the HTTP_INPUT filter for HTTP requests and responses from @@ -769,6 +770,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ctx->state = BODY_NONE; ctx->remaining = 0; ctx->limit_used = 0; + ctx->eos_sent = 0; /* LimitRequestBody does not apply to proxied responses. * Consider implementing this check in its own filter. @@ -817,6 +819,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, APR_BRIGADE_INSERT_TAIL(bb, e); e = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, e); + ctx->eos_sent = 1; return ap_pass_brigade(f->r->output_filters, bb); } } @@ -835,6 +838,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, if (ctx->state == BODY_NONE && f->r->proxyreq != PROXYREQ_RESPONSE) { e = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(b, e); + ctx->eos_sent = 1; return APR_SUCCESS; } @@ -886,6 +890,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, APR_BRIGADE_INSERT_TAIL(bb, e); e = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, e); + ctx->eos_sent = 1; return ap_pass_brigade(f->r->output_filters, bb); } @@ -895,23 +900,26 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_get_mime_headers(f->r); e = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(b, e); + ctx->eos_sent = 1; return APR_SUCCESS; } } } + if (ctx->eos_sent) { + e = apr_bucket_eos_create(f->c->bucket_alloc); + APR_BRIGADE_INSERT_TAIL(b, e); + return APR_SUCCESS; + } + if (!ctx->remaining) { switch (ctx->state) { case BODY_NONE: - if (f->r->proxyreq != PROXYREQ_RESPONSE) { - e = apr_bucket_eos_create(f->c->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(b, e); - return APR_SUCCESS; - } break; case BODY_LENGTH: e = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(b, e); + ctx->eos_sent = 1; return APR_SUCCESS; case BODY_CHUNK: { @@ -950,6 +958,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, APR_BRIGADE_INSERT_TAIL(bb, e); e = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, e); + ctx->eos_sent = 1; return ap_pass_brigade(f->r->output_filters, bb); } @@ -959,6 +968,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_get_mime_headers(f->r); e = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(b, e); + ctx->eos_sent = 1; return APR_SUCCESS; } } @@ -1010,6 +1020,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, APR_BRIGADE_INSERT_TAIL(bb, e); e = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, e); + ctx->eos_sent = 1; return ap_pass_brigade(f->r->output_filters, bb); } }