From 1ed6c060bfe792720e49521b1fa61464d7bbca87 Mon Sep 17 00:00:00 2001 From: Nick Kew Date: Fri, 16 Nov 2007 14:20:03 +0000 Subject: [PATCH] =?utf8?q?Deal=20with=20unrecognised=20Transfer-Encoding?= =?utf8?q?=20headers.=20PR#43882=20(Bj=C3=B6rn=20H=C3=B6hrmann)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@595672 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ modules/http/http_filters.c | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index c7201fac72..855be86bfb 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.3.0 [ When backported to 2.2.x, remove entry from this file ] + *) core: Handle unrecognised transfer-encodings. + PR 43882 [Nick Kew] + *) core: Avoid some unexpected connection closes by telling the client that the connection is not persistent if the MPM process handling the request is already exiting when the response header is built. diff --git a/modules/http/http_filters.c b/modules/http/http_filters.c index db18d6f40b..69a4b927fd 100644 --- a/modules/http/http_filters.c +++ b/modules/http/http_filters.c @@ -115,9 +115,26 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, lenp = apr_table_get(f->r->headers_in, "Content-Length"); if (tenc) { - if (!strcasecmp(tenc, "chunked")) { + /* RFC2616 allows qualifiers, so use strncasecmp */ + if (!strncasecmp(tenc, "chunked", 7)) { ctx->state = BODY_CHUNK; } + else { + /* Something that isn't in HTTP, unless some future + * edition defines new transfer ecodings, is unsupported. + */ + apr_bucket_brigade *bb; + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, f->r, + "Unknown Transfer-Encoding: %s", tenc); + bb = apr_brigade_create(f->r->pool, f->c->bucket_alloc); + e = ap_bucket_error_create(HTTP_NOT_IMPLEMENTED, NULL, + f->r->pool, f->c->bucket_alloc); + 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); + } } else if (lenp) { char *endstr; -- 2.40.0