]> granicus.if.org Git - apache/commitdiff
Deal with unrecognised Transfer-Encoding headers.
authorNick Kew <niq@apache.org>
Fri, 16 Nov 2007 14:20:03 +0000 (14:20 +0000)
committerNick Kew <niq@apache.org>
Fri, 16 Nov 2007 14:20:03 +0000 (14:20 +0000)
PR#43882 (Björn Höhrmann)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@595672 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/http/http_filters.c

diff --git a/CHANGES b/CHANGES
index c7201fac72c19b291820718fe6f9f8e4f74460f0..855be86bfb7670ac0d3b68909995d12621304e48 100644 (file)
--- 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.
index db18d6f40b8897ae7b617b6488e10b2112fb40b6..69a4b927fd4a798e96e9851ca96afae7e2bbfd41 100644 (file)
@@ -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;