]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Support the suppress-error-charset setting, as with Apache 1.3.x.
authorJeff Trawick <trawick@apache.org>
Mon, 16 May 2005 10:41:42 +0000 (10:41 +0000)
committerJeff Trawick <trawick@apache.org>
Mon, 16 May 2005 10:41:42 +0000 (10:41 +0000)
With Apache 1.3.x, it is a bit simpler as the request does
not go through ap_make_content_type().

Modules can set custom error responses but not be able to
set the charset, so they have to code the charset in the
html.  Thus, it is useful to preserve 1.3.x behavior exactly.

PR: 26467

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

CHANGES
docs/manual/env.xml
include/http_core.h
modules/http/http_protocol.c
server/protocol.c

diff --git a/CHANGES b/CHANGES
index 660b7484b8304402d226d66461df20954ab793af..7d4ea1e90ec73186f348a969020ec7fd7cd2febf 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@ Changes with Apache 2.1.5
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) Support the suppress-error-charset setting, as with Apache 1.3.x.
+     PR 31274.  [Jeff Trawick]
+
   *) Prevent hangs of child processes when writing to piped loggers at
      the time of graceful restart.  PR 26467.  [Jeff Trawick]
   
index 41875320b48b897ae2dd777ab224f9900a972c72..048f5b1cd73eb22185f26995205c0fe0364c61fc 100644 (file)
    <section id="suppress-error-charset">
        <title>suppress-error-charset</title>
 
-    <p><em>Available in versions after 2.0.40</em></p>
+    <p><em>Available in versions 2.2 and later</em></p>
 
     <p>When Apache issues a redirect in response to a client request,
     the response includes some actual text to be displayed in case
index f20e8a807674e149d31f6641fe0d8a5eb50ae611..175055d51c07a122c799c3c21a6d827d15330cd6 100644 (file)
@@ -332,6 +332,9 @@ typedef struct {
     char **response_code_strings; /* from ap_custom_response(), not from
                                    * ErrorDocument
                                    */
+    /* Should addition of charset= be suppressed for this request?
+     */
+    int suppress_charset;
 } core_request_config;
 
 /* Standard entries that are guaranteed to be accessible via
index 9e2f18f2debb1787cb7ef51c07cb35dba29e4ee6..d4b0429f52dd4c46e93817290706675794a6087c 100644 (file)
@@ -1157,7 +1157,19 @@ AP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error)
         r->content_languages = NULL;
         r->content_encoding = NULL;
         r->clength = 0;
-        ap_set_content_type(r, "text/html; charset=iso-8859-1");
+
+        if (apr_table_get(r->subprocess_env,
+                          "suppress-error-charset") != NULL) {
+            core_request_config *request_conf =
+                        ap_get_module_config(r->request_config, &core_module);
+            request_conf->suppress_charset = 1; /* avoid adding default
+                                                 * charset later
+                                                 */
+            ap_set_content_type(r, "text/html");
+        }
+        else {
+            ap_set_content_type(r, "text/html; charset=iso-8859-1");
+        }
 
         if ((status == HTTP_METHOD_NOT_ALLOWED)
             || (status == HTTP_NOT_IMPLEMENTED)) {
index 2ef8438003653d6a5e8399aa5c27d2b8904ee8b8..60b1a9c139d1456bac71e2bd10db69483e152ddb 100644 (file)
@@ -106,6 +106,7 @@ AP_DECLARE(const char *)ap_make_content_type(request_rec *r, const char *type)
     core_dir_config *conf =
         (core_dir_config *)ap_get_module_config(r->per_dir_config,
                                                 &core_module);
+    core_request_config *request_conf;
     apr_size_t type_len;
 
     if (!type) {
@@ -116,6 +117,12 @@ AP_DECLARE(const char *)ap_make_content_type(request_rec *r, const char *type)
         return type;
     }
 
+    request_conf =
+        ap_get_module_config(r->request_config, &core_module);
+    if (request_conf->suppress_charset) {
+        return type;
+    }
+
     type_len = strlen(type);
 
     if (apr_strmatch(charset_pattern, type, type_len) != NULL) {