You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jim Jagielski <ji...@jaguNET.com> on 2000/02/03 01:47:51 UTC

[PATCH] AddDefaultCharset now does it all

Here's the patch I refered to regarding having AddDefaultCharset
be "self contained"... Comments??


Index: htdocs/manual/mod/core.html
===================================================================
RCS file: /export/home/cvs/apache-1.3/htdocs/manual/mod/core.html,v
retrieving revision 1.163
diff -u -r1.163 core.html
--- core.html	2000/02/02 20:43:11	1.163
+++ core.html	2000/02/03 00:35:05
@@ -24,7 +24,6 @@
 <LI><A HREF="#accessconfig">AccessConfig</A>
 <LI><A HREF="#accessfilename">AccessFileName</A>
 <LI><A HREF="#adddefaultcharset">AddDefaultCharset</A>
-<LI><A HREF="#adddefaultcharsetname">AddDefaultCharsetName</A>
 <LI><A HREF="#addmodule">AddModule</A>
 <LI><A HREF="#allowoverride">AllowOverride</A>
 <LI><A HREF="#authname">AuthName</A>
@@ -167,38 +166,23 @@
 
 <H2><A NAME="adddefaultcharset">AddDefaultCharset directive</A></H2>
 <A HREF="directive-dict.html#Syntax" REL="Help"><STRONG>Syntax:</STRONG></A> 
-AddDefaultCharset <EM>on / off</EM><BR>
+AddDefaultCharset <EM>None / Default / charset</EM><BR>
 <A HREF="directive-dict.html#Context" REL="Help" ><STRONG>Context:</STRONG></A> 
 all<BR>
 <A HREF="directive-dict.html#Status" REL="Help" ><STRONG>Status:</STRONG></A> 
 core<BR>
 <A HREF="directive-dict.html#Default" REL="Help"><STRONG>Default:</STRONG></A>
-<CODE>AddDefaultCharset off</CODE><BR>
+<CODE>AddDefaultCharset None</CODE><BR>
 <A HREF="directive-dict.html#Compatibility" REL="Help"><STRONG>Compatibility:
-</STRONG></A> AddDefaultCharset is only available in Apache 1.3.12 and later<P>
-If enabled, any response that does not have any parameter on the content 
-type in the HTTP headers will have a charset parameter added specifying 
-the character set the client should use for the document.  This will 
-override any character set specified in the body of the document via a 
-<CODE>META</CODE> tag.  The character set added is specified by the 
-<CODE>AddDefaultCharsetName</CODE> directive.
-<P><HR>
-
-<H2><A NAME="adddefaultcharsetname">AddDefaultCharsetName directive</A></H2>
-<A HREF="directive-dict.html#Syntax" REL="Help"><STRONG>Syntax:</STRONG></A> 
-AddDefaultCharsetName <EM>charset</EM><BR>
-<A HREF="directive-dict.html#Context" REL="Help" ><STRONG>Context:</STRONG></A> 
-all<BR>
-<A HREF="directive-dict.html#Status" REL="Help" ><STRONG>Status:</STRONG></A> 
-core<BR>
-<A HREF="directive-dict.html#Default" REL="Help"><STRONG>Default:</STRONG></A>
-<CODE>AddDefaultCharsetName iso-8859-1</CODE><BR>
-<A HREF="directive-dict.html#Compatibility" REL="Help"><STRONG>Compatibility:
-</STRONG></A> AddDefaultCharsetName is only available in Apache 1.3.12 and 
+</STRONG></A> AddDefaultCharset is only available in Apache 1.3.12 and 
 later<P>
 This directive specifies the name of the character set that will be added
-if the <A HREF="#adddefaultcharset">AddDefaultCharset</A> directive is 
-enabled.
+to any response that does not have any parameter on the content
+type in the HTTP headers. This will override any character set specified
+in the body of the document via a <CODE>META</CODE> tag. A setting
+of <CODE>AddDefaultCharset None</CODE> disables this functionality.
+<CODE>AddDefaultCharset Default</CODE> is the exact same as
+<code>AddDefaultCharsetName iso-8859-1</code>.
 <P><HR>
 
 <H2><A NAME="addmodule">AddModule directive</A></H2>
Index: htdocs/manual/mod/directives.html
===================================================================
RCS file: /export/home/cvs/apache-1.3/htdocs/manual/mod/directives.html,v
retrieving revision 1.61
diff -u -r1.61 directives.html
--- directives.html	2000/01/31 22:56:48	1.61
+++ directives.html	2000/02/03 00:35:09
@@ -31,6 +31,7 @@
 <LI><A HREF="mod_autoindex.html#addaltbyencoding">AddAltByEncoding</A>
 <LI><A HREF="mod_autoindex.html#addaltbytype">AddAltByType</A>
 <LI><A HREF="mod_mime.html#addcharset">AddCharset</A>
+<LI><A HREF="core.html#adddefaultcharset">AddDefaultCharset</A>
 <LI><A HREF="mod_autoindex.html#adddescription">AddDescription</A>
 <LI><A HREF="mod_mime.html#addencoding">AddEncoding</A>
 <LI><A HREF="mod_mime.html#addhandler">AddHandler</A>
Index: src/main/http_core.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v
retrieving revision 1.278
diff -u -r1.278 http_core.c
--- http_core.c	2000/02/02 20:43:46	1.278
+++ http_core.c	2000/02/03 00:35:22
@@ -1047,24 +1047,22 @@
 #endif /*GPROF*/
 
 static const char *set_add_default_charset(cmd_parms *cmd, 
-	core_dir_config *d, int arg)
-{
-    const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
-    if (err != NULL) {
-        return err;
-    }
-    d->add_default_charset = arg != 0;
-    return NULL;
-}
-
-static const char *set_add_default_charset_name(cmd_parms *cmd, 
 	core_dir_config *d, char *arg)
 {
     const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
     if (err != NULL) {
         return err;
+    }
+    if (!strcasecmp(arg, "None"))
+       d->add_default_charset = 0;
+    else if (!strcasecmp(arg, "Default")) {
+       d->add_default_charset = 1;
+       d->add_default_charset_name = DEFAULT_ADD_DEFAULT_CHARSET_NAME;
+    }
+    else {
+       d->add_default_charset = 1;
+       d->add_default_charset_name = arg;
     }
-    d->add_default_charset_name = arg;
     return NULL;
 }
 
@@ -2819,10 +2817,8 @@
 { "GprofDir", set_gprof_dir, NULL, RSRC_CONF, TAKE1,
   "Directory to plop gmon.out files" },
 #endif
-{ "AddDefaultCharset", set_add_default_charset, NULL, OR_FILEINFO, FLAG,
-  "whether or not to add a default charset to any Content-Type without one" },
-{ "AddDefaultCharsetName", set_add_default_charset_name, NULL, OR_FILEINFO, 
-  TAKE1, "The name of the charset to add if AddDefaultCharset is enabled" },
+{ "AddDefaultCharset", set_add_default_charset, NULL, OR_FILEINFO, 
+  TAKE1, "The name of the default charset to add to any Content-Type without one or 'None' to disable" },
 
 /* Old resource config file commands */
   
-- 
===========================================================================
   Jim Jagielski   [|]   jim@jaguNET.com   [|]   http://www.jaguNET.com/
                "Are you suggesting coconuts migrate??"

Re: [PATCH] AddDefaultCharset now does it all

Posted by Martin Kraemer <Ma...@Mch.SNI.De>.
On Wed, Feb 02, 2000 at 07:47:51PM -0500, Jim Jagielski wrote:
> Here's the patch I refered to regarding having AddDefaultCharset
> be "self contained"... Comments??

+1 (untested): I prefer avoiding unneccessary bloating of the number
of directives.

    Martin
-- 
  <Ma...@MchP.Siemens.De>      |       Fujitsu Siemens
       <ma...@apache.org>              |   81730  Munich,  Germany
((See you at ApacheCon 2000 in Orlanda, Florida, March 8-10, 2000!))
		   <URL:http://ApacheCon.Com/>