]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Fold in patch related to PR42993
authorJim Jagielski <jim@apache.org>
Thu, 9 Aug 2007 15:32:42 +0000 (15:32 +0000)
committerJim Jagielski <jim@apache.org>
Thu, 9 Aug 2007 15:32:42 +0000 (15:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@564245 13f79535-47bb-0310-9956-ffa450edef68

STATUS
modules/filters/mod_deflate.c

diff --git a/STATUS b/STATUS
index 7c33ad2c9b8d10cb252a23e5111d329da3507537..41d060423b816b0ead3acf1550ad0011efdc8ac5 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -78,11 +78,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-    * mod_deflate: fix content_encoding detection from different
-      sources in inflate_out filter.
-      PR: 42993
-      http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_deflate.c?r1=563230&r2=563803
-      +1: niq, rpluem, jim
       
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
 
index 98ecd3b72c3f9e70d91a8205706d6b7390a021f8..f82b75b7c009688ba1d54faedbe40e281c12ae13 100644 (file)
@@ -88,31 +88,52 @@ static const char deflate_magic[2] = { '\037', '\213' };
  * If a request has multiple encodings, we need the gzip
  * to be the outermost non-identity encoding.
  */
-static int check_gzip(apr_pool_t *pool, apr_table_t *hdrs)
+static int check_gzip(request_rec *r, apr_table_t *hdrs1, apr_table_t *hdrs2)
 {
     int found = 0;
+    apr_table_t *hdrs = hdrs1;
     const char *encoding = apr_table_get(hdrs, "Content-Encoding");
+
+    if (!encoding && (hdrs2 != NULL)) {
+        /* the output filter has two tables and a content_encoding to check */
+        encoding = apr_table_get(hdrs2, "Content-Encoding");
+        hdrs = hdrs2;
+        if (!encoding) {
+            encoding = r->content_encoding;
+            hdrs = NULL;
+        }
+    }
     if (encoding && *encoding) {
 
         /* check the usual/simple case first */
         if (!strcasecmp(encoding, "gzip")
             || !strcasecmp(encoding, "x-gzip")) {
             found = 1;
-            apr_table_unset(hdrs, "Content-Encoding");
+            if (hdrs) {
+                apr_table_unset(hdrs, "Content-Encoding");
+            }
+            else {
+                r->content_encoding = NULL;
+            }
         }
         else if (ap_strchr_c(encoding, ',') != NULL) {
             /* If the outermost encoding isn't gzip, there's nowt
              * we can do.  So only check the last non-identity token
              */
-            char *new_encoding = apr_pstrdup(pool, encoding);
+            char *new_encoding = apr_pstrdup(r->pool, encoding);
             char *ptr;
             for(;;) {
                 char *token = ap_strrchr(new_encoding, ',');
                 if (!token) {        /* gzip:identity or other:identity */
                     if (!strcasecmp(new_encoding, "gzip")
                         || !strcasecmp(new_encoding, "x-gzip")) {
-                        apr_table_unset(hdrs, "Content-Encoding");
                         found = 1;
+                        if (hdrs) {
+                            apr_table_unset(hdrs, "Content-Encoding");
+                        }
+                        else {
+                            r->content_encoding = NULL;
+                        }
                     }
                     break; /* seen all tokens */
                 }
@@ -120,7 +141,12 @@ static int check_gzip(apr_pool_t *pool, apr_table_t *hdrs)
                 if (!strcasecmp(ptr, "gzip")
                     || !strcasecmp(ptr, "x-gzip")) {
                     *token = '\0';
-                    apr_table_setn(hdrs, "Content-Encoding", new_encoding);
+                    if (hdrs) {
+                        apr_table_setn(hdrs, "Content-Encoding", new_encoding);
+                    }
+                    else {
+                        r->content_encoding = new_encoding;
+                    }
                     found = 1;
                 }
                 else if (!ptr[0] || !strcasecmp(ptr, "identity")) {
@@ -735,7 +761,7 @@ static apr_status_t deflate_in_filter(ap_filter_t *f,
          *
          * If not, we just remove ourself.
          */
-        if (check_gzip(r->pool, r->headers_in) == 0) {
+        if (check_gzip(r, r->headers_in, NULL) == 0) {
             ap_remove_input_filter(f);
             return ap_get_brigade(f->next, bb, mode, block, readbytes);
         }
@@ -990,7 +1016,7 @@ static apr_status_t inflate_out_filter(ap_filter_t *f,
          * Let's see what our current Content-Encoding is.
          * Only inflate if gzipped.
          */
-        if (check_gzip(r->pool, r->headers_out) == 0) {
+        if (check_gzip(r, r->headers_out, r->err_headers_out) == 0) {
             ap_remove_output_filter(f);
             return ap_pass_brigade(f->next, bb);
         }