From: Nick Kew Date: Fri, 16 Nov 2007 14:20:03 +0000 (+0000) Subject: Deal with unrecognised Transfer-Encoding headers. X-Git-Tag: 2.3.0~1253 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ed6c060bfe792720e49521b1fa61464d7bbca87;p=thirdparty%2Fapache%2Fhttpd.git Deal with unrecognised Transfer-Encoding headers. PR#43882 (Björn Höhrmann) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@595672 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index c7201fac72c..855be86bfb7 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 db18d6f40b8..69a4b927fd4 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;