You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2006/02/23 22:41:01 UTC

svn commit: r380232 - in /httpd/httpd/trunk: CHANGES modules/filters/mod_charset_lite.c

Author: trawick
Date: Thu Feb 23 13:40:59 2006
New Revision: 380232

URL: http://svn.apache.org/viewcvs?rev=380232&view=rev
Log:
mod_charset_lite: Remove Content-Length when output filter can
invalidate it.  Warn when input filter can invalidate it.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/filters/mod_charset_lite.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/CHANGES?rev=380232&r1=380231&r2=380232&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Thu Feb 23 13:40:59 2006
@@ -2,6 +2,10 @@
 Changes with Apache 2.3.0
   [Remove entries to the current 2.0 and 2.2 section below, when backported]
 
+  *) mod_charset_lite: Remove Content-Length when output filter can 
+     invalidate it.  Warn when input filter can invalidate it.
+     [Jeff Trawick]
+
   *) Ensure that the proper status line is written to the client, fixing
      incorrect status lines caused by filters which modify r->status without 
      resetting r->status_line, such as the built-in byterange filter.

Modified: httpd/httpd/trunk/modules/filters/mod_charset_lite.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/filters/mod_charset_lite.c?rev=380232&r1=380231&r2=380232&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_charset_lite.c (original)
+++ httpd/httpd/trunk/modules/filters/mod_charset_lite.c Thu Feb 23 13:40:59 2006
@@ -85,6 +85,7 @@
  */
 typedef struct charset_filter_ctx_t {
     apr_xlate_t *xlate;
+    int is_sb;              /* single-byte translation? */
     charset_dir_t *dc;
     ees_t ees;              /* extended error status */
     apr_size_t saved;
@@ -323,6 +324,9 @@
                           dc->charset_default, dc->charset_source);
             return HTTP_INTERNAL_SERVER_ERROR;
         }
+        if (apr_xlate_sb_get(input_ctx->xlate, &input_ctx->is_sb) != APR_SUCCESS) {
+            input_ctx->is_sb = 0;
+        }
     }
 
     return DECLINED;
@@ -862,6 +866,11 @@
                               dc->charset_source, dc->charset_default);
                 ctx->noop = 1;
             }
+            else {
+                if (apr_xlate_sb_get(ctx->xlate, &ctx->is_sb) != APR_SUCCESS) {
+                    ctx->is_sb = 0;
+                }
+            }
         }
         else {
                 ctx->noop = 1;
@@ -883,6 +892,12 @@
     if (!ctx->ran) {  /* filter never ran before */
         chk_filter_chain(f);
         ctx->ran = 1;
+        if (!ctx->noop && !ctx->is_sb) {
+            /* We're not converting between two single-byte charsets, so unset
+             * Content-Length since it is unlikely to remain the same.
+             */
+            apr_table_unset(f->r->headers_out, "Content-Length");
+        }
     }
 
     if (ctx->noop) {
@@ -1041,6 +1056,17 @@
     if (!ctx->ran) {  /* filter never ran before */
         chk_filter_chain(f);
         ctx->ran = 1;
+        if (!ctx->noop && !ctx->is_sb) {
+            /* We're not converting between two single-byte charsets, so note
+             * that some handlers can't deal with it.
+             * It doesn't help to unset Content-Length in the input header
+             * table since in all likelihood the handler has already seen it.
+             */
+            if (dc->debug >= DBGLVL_PMC) {
+                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r,
+                              "Request body length may change, breaking some requests");
+            }
+        }
     }
 
     if (ctx->noop) {