]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r570532, r570535, r570558 from trunk:
authorJim Jagielski <jim@apache.org>
Wed, 29 Aug 2007 22:37:14 +0000 (22:37 +0000)
committerJim Jagielski <jim@apache.org>
Wed, 29 Aug 2007 22:37:14 +0000 (22:37 +0000)
IndexOptions ContentType=text/html Charset=UTF-8
magic.

Document new IndexOptions options

Make Bill happy ;)

Submitted by: jim
Reviewed by: root

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.0.x@570961 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/mod/mod_autoindex.xml
modules/generators/mod_autoindex.c

diff --git a/CHANGES b/CHANGES
index 9c023909c8089f31e3c9823e72625f41f4c333ff..b0ad231cd99892fa8485414ac3527959382f9298 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,11 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.0.61
 
+  *) mod_autoindex: Add in Type and Charset options to IndexOptions
+     directive. This allows the admin to explicitly set the
+     content-type and charset of the generated page.
+     [Jim Jagielski]
+
   *) main core: Emit errors during the initial apr_app_initialize()
      or apr_pool_create() (when apr-based error reporting is not ready).
      [William Rowe, Jeff Trawick]
index c2160b57aa3f775403f7edc9b817831301d126ef..6f3437de819fbc89ff5a0c9f8471965e5fd74bfe 100644 (file)
@@ -525,6 +525,36 @@ indexing</description>
     of</p>
 
     <dl>
+      <dt><a name="indexoptions.charset"
+               id="indexoptions.charset"
+      >Charset=<var>character-set</var></a> (<em>Apache 2.0.61 and
+      later</em>)</dt>
+
+      <dd>The <code>Charset</code> keyword allows you to
+      specify the character set of the generated page. The
+      default is either <var>ISO-8859-1</var> or <var>UTF-8</var>,
+      depending on whether the underlying file system is unicode
+      or not.
+
+      <example><title>Example:</title>
+        IndexOptions Charset=UTF-8
+      </example>
+      </dd>
+      
+      <dt><a name="indexoptions.type"
+               id="indexoptions.type"
+      >Type=<var>MIME content-type</var></a> (<em>Apache 2.0.61 and
+      later</em>)</dt>
+
+      <dd>The <code>Type</code> keyword allows you to
+      specify the MIME content-type of the generated page. The default
+      is <var>text/html</var>.
+
+      <example><title>Example:</title>
+        IndexOptions Type=text/plain
+      </example>
+      </dd>
+      
       <dt><a name="indexoptions.descriptionwidth"
                id="indexoptions.descriptionwidth"
       >DescriptionWidth=[<var>n</var> | *]</a> (<em>Apache 2.0.23 and
index 7db45f9b4c98cbc7d116668937af5ef0ed31d330..f98f12f37ac3bba76b5df18e571f4d39702175f5 100644 (file)
@@ -136,6 +136,8 @@ typedef struct autoindex_config_struct {
     apr_array_header_t *hdr_list;
     apr_array_header_t *rdme_list;
 
+    char *ctype;
+    char *charset;
 } autoindex_config_rec;
 
 static char c_by_encoding, c_by_type, c_by_path;
@@ -459,6 +461,12 @@ static const char *add_opts(cmd_parms *cmd, void *d, const char *optstr)
                 d_cfg->desc_adjust = K_NOADJUST;
             }
         }
+        else if (!strncasecmp(w, "Type=", 5)) {
+            d_cfg->ctype = apr_pstrdup(cmd->pool, &w[5]);
+        }
+        else if (!strncasecmp(w, "Charset=", 8)) {
+            d_cfg->charset = apr_pstrdup(cmd->pool, &w[8]);
+        }
         else {
             return "Invalid directory indexing option";
         }
@@ -598,6 +606,9 @@ static void *merge_autoindex_configs(apr_pool_t *p, void *basev, void *addv)
     new->icon_height = add->icon_height ? add->icon_height : base->icon_height;
     new->icon_width = add->icon_width ? add->icon_width : base->icon_width;
 
+    new->ctype = add->ctype ? add->ctype : base->ctype;
+    new->charset = add->charset ? add->charset : base->charset;
+
     new->alt_list = apr_array_append(p, add->alt_list, base->alt_list);
     new->ign_list = apr_array_append(p, add->ign_list, base->ign_list);
     new->hdr_list = apr_array_append(p, add->hdr_list, base->hdr_list);
@@ -1941,6 +1952,8 @@ static int index_directory(request_rec *r,
     char *colargs;
     char *fullpath;
     apr_size_t dirpathlen;
+    char *ctype = "text/html";
+    char *charset;
 
     if ((status = apr_dir_open(&thedir, name, r->pool)) != APR_SUCCESS) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
@@ -1948,11 +1961,27 @@ static int index_directory(request_rec *r,
         return HTTP_FORBIDDEN;
     }
 
+    if (autoindex_conf->ctype) {
+        ctype = autoindex_conf->ctype;
+    }
+    if (autoindex_conf->charset) {
+        charset = autoindex_conf->charset;
+    }
+    else {
 #if APR_HAS_UNICODE_FS
-    ap_set_content_type(r, "text/html;charset=utf-8");
+        charset = "UTF-8";
 #else
-    ap_set_content_type(r, "text/html");
+        charset = "ISO-8859-1";
 #endif
+    }
+    if (*charset) {
+        ap_set_content_type(r, apr_pstrcat(r->pool, ctype, ";charset=",
+                            charset, NULL));
+    }
+    else {
+        ap_set_content_type(r, ctype);
+    }
+
     if (autoindex_opts & TRACK_MODIFIED) {
         ap_update_mtime(r, r->finfo.mtime);
         ap_set_last_modified(r);