From 64350668a2c1a8d83f65cace8a5f0a41c1babae0 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Mon, 12 Dec 2016 12:06:06 +0000 Subject: [PATCH] Follow up to r1773761: don't check_headers() more than once. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1773779 13f79535-47bb-0310-9956-ffa450edef68 --- modules/http/http_filters.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/http/http_filters.c b/modules/http/http_filters.c index c2548ec88b..1c00115fe7 100644 --- a/modules/http/http_filters.c +++ b/modules/http/http_filters.c @@ -1199,15 +1199,17 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, if (!ctx) { ctx = f->ctx = apr_pcalloc(r->pool, sizeof(header_filter_ctx)); } - else if (ctx->headers_sent) { - /* r->header_only or HTTP_NO_CONTENT case below, don't let - * the body pass trhough. - */ - apr_brigade_cleanup(b); - return APR_SUCCESS; - } - if (!ctx->headers_error && !check_headers(r)) { + if (ctx->headers_sent) { + if (r->header_only || r->status == HTTP_NO_CONTENT) { + /* r->header_only or HTTP_NO_CONTENT case below, don't let + * the body pass trhough. + */ + apr_brigade_cleanup(b); + return APR_SUCCESS; + } + } + else if (!ctx->headers_error && !check_headers(r)) { /* Eat body until EOS */ ctx->headers_error = 1; } @@ -1382,10 +1384,10 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, terminate_header(b2); ap_pass_brigade(f->next, b2); + ctx->headers_sent = 1; if (r->header_only || r->status == HTTP_NO_CONTENT) { apr_brigade_cleanup(b); - ctx->headers_sent = 1; return APR_SUCCESS; } -- 2.40.0