That feature avoids the addition of "charset=iso-8859-1" on certain error responses. But its dependence on SetEnv means it only works if the request reached fixup hook before "failing." That means it can't be used like this:
Redirect /Contacts http://www.example.com/contacts <Location /Contacts> SetEnv suppress-error-charset 1 </Location> This patch turns it into a directive: <Location /Contacts> SuppressErrorCharset On </Location> Does anybody even care?
Index: src/include/http_core.h =================================================================== --- src/include/http_core.h (revision 165318) +++ src/include/http_core.h (working copy) @@ -318,6 +318,8 @@ /* Digest auth. */ char *ap_auth_nonce; + /* if set, don't include "charset=" on error responses */ + ap_flag_e suppress_error_charset; } core_dir_config; /* Per-server core configuration */ Index: src/main/http_protocol.c =================================================================== --- src/main/http_protocol.c (revision 165318) +++ src/main/http_protocol.c (working copy) @@ -2751,6 +2751,7 @@ int idx = ap_index_of_response(status); char *custom_response; const char *location = ap_table_get(r->headers_out, "Location"); + core_dir_config *conf; #ifdef CHARSET_EBCDIC /* Error Responses (builtin / string literal / redirection) are TEXT! */ ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1); @@ -2828,7 +2829,10 @@ r->content_languages = NULL; r->content_encoding = NULL; r->clength = 0; - if (ap_table_get(r->subprocess_env, + conf = (core_dir_config *)ap_get_module_config(r->per_dir_config, + &core_module); + if (conf->suppress_error_charset == AP_FLAG_ON || + ap_table_get(r->subprocess_env, "suppress-error-charset") != NULL) { r->content_type = "text/html"; } Index: src/main/http_core.c =================================================================== --- src/main/http_core.c (revision 165318) +++ src/main/http_core.c (working copy) @@ -143,6 +143,8 @@ conf->etag_add = ETAG_UNSET; conf->etag_remove = ETAG_UNSET; + conf->suppress_error_charset = AP_FLAG_UNSET; + return (void *)conf; } @@ -319,6 +321,10 @@ conf->cgi_command_args = new->cgi_command_args; } + if (new->suppress_error_charset != AP_FLAG_UNSET) { + conf->suppress_error_charset = new->suppress_error_charset; + } + return (void*)conf; } @@ -1214,6 +1220,12 @@ } return NULL; } +static const char *set_suppress_error_charset(cmd_parms *cmd, + core_dir_config *d, int arg) +{ + d->suppress_error_charset = arg != 0 ? AP_FLAG_ON : AP_FLAG_OFF; + return NULL; +} static const char *set_accept_mutex(cmd_parms *cmd, void *dummy, char *arg) { return ap_init_mutex_method(arg); @@ -3508,7 +3520,8 @@ #endif { "AddDefaultCharset", set_add_default_charset, NULL, OR_FILEINFO, TAKE1, "The name of the default charset to add to any Content-Type without one or 'Off' to disable" }, - +{ "SuppressErrorCharset", set_suppress_error_charset, NULL, OR_FILEINFO, + FLAG, "Whether or not to suppress addition of charset= on error responses" }, /* Old resource config file commands */ { "AccessFileName", set_access_name, NULL, RSRC_CONF, RAW_ARGS,