httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Simonson" <s...@us.ibm.com>
Subject [PATCH] mod_autoindex HeaderName/ReadmeName content_type
Date Wed, 29 Aug 2001 13:41:39 GMT
This patch is to set the content_type to the default if the subrequest
request_rec content_type is NULL.

Rob Simonson
simo@us.ibm.com

==========================================================
--- mod_autoindex.c.asfsave.c Wed Aug 29 08:29:17 2001
+++ mod_autoindex.c Wed Aug 29 08:32:15 2001
@@ -999,49 +999,49 @@
     && (rr->status == HTTP_OK)
     && (rr->filename != NULL)
     && rr->finfo.filetype == APR_REG) {
+        if (rr->content_type == NULL)
+            rr->content_type = ap_default_type(rr);
     /*
      * Check for the two specific cases we allow: text/html and
      * text/anything-else.  The former is allowed to be processed for
      * SSIs.
      */
-    if (rr->content_type != NULL) {
-        if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type),
-                  "text/html")) {
-         /* Hope everything will work... */
-         emit_amble = 0;
-         emit_H1 = 0;
+        if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type),
+                        "text/html")) {
+            /* Hope everything will work... */
+            emit_amble = 0;
+            emit_H1 = 0;

-         if (! suppress_amble) {
-             emit_preamble(r, title);
-         }
-         /*
-          * If there's a problem running the subrequest, display the
-          * preamble if we didn't do it before -- the header file
-          * didn't get displayed.
-          */
-         if (ap_run_sub_req(rr) != OK) {
-             /* It didn't work */
-             emit_amble = suppress_amble;
-             emit_H1 = 1;
-         }
-        }
-        else if (!strncasecmp("text/", rr->content_type, 5)) {
-         /*
-          * If we can open the file, prefix it with the preamble
-          * regardless; since we'll be sending a <pre> block around
-          * the file's contents, any HTML header it had won't end up
-          * where it belongs.
-          */
-         if (apr_file_open(&f, rr->filename, APR_READ,
-                            APR_OS_DEFAULT, r->pool) == APR_SUCCESS) {
-             emit_preamble(r, title);
-             emit_amble = 0;
-             do_emit_plain(r, f);
-             apr_file_close(f);
-             emit_H1 = 0;
-         }
-        }
-    }
+            if (! suppress_amble) {
+                emit_preamble(r, title);
+            }
+            /*
+             * If there's a problem running the subrequest, display the
+             * preamble if we didn't do it before -- the header file
+             * didn't get displayed.
+             */
+            if (ap_run_sub_req(rr) != OK) {
+                /* It didn't work */
+                emit_amble = suppress_amble;
+                emit_H1 = 1;
+            }
+        }
+        else if (!strncasecmp("text/", rr->content_type, 5)) {
+            /*
+             * If we can open the file, prefix it with the preamble
+             * regardless; since we'll be sending a <pre> block around
+             * the file's contents, any HTML header it had won't end up
+             * where it belongs.
+             */
+            if (apr_file_open(&f, rr->filename, APR_READ,
+                              APR_OS_DEFAULT, r->pool) == APR_SUCCESS) {
+                emit_preamble(r, title);
+                emit_amble = 0;
+                do_emit_plain(r, f);
+                apr_file_close(f);
+                emit_H1 = 0;
+            }
+        }
     }

     if (emit_amble) {
@@ -1082,32 +1082,32 @@
     && (rr->status == HTTP_OK)
     && (rr->filename != NULL)
     && rr->finfo.filetype == APR_REG) {
+        if (rr->content_type == NULL)
+            rr->content_type = ap_default_type(rr);
     /*
      * Check for the two specific cases we allow: text/html and
      * text/anything-else.  The former is allowed to be processed for
      * SSIs.
-     */
-    if (rr->content_type != NULL) {
-        if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type),
-                  "text/html")) {
-         if (ap_run_sub_req(rr) == OK) {
-             /* worked... */
-             suppress_sig = 1;
-             suppress_post = suppress_amble;
-         }
-        }
-        else if (!strncasecmp("text/", rr->content_type, 5)) {
-         /*
-          * If we can open the file, suppress the signature.
-          */
-         if (apr_file_open(&f, rr->filename, APR_READ,
-                            APR_OS_DEFAULT, r->pool) == APR_SUCCESS) {
-             do_emit_plain(r, f);
-             apr_file_close(f);
-             suppress_sig = 1;
-         }
-        }
-    }
+         */
+        if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type),
+                        "text/html")) {
+            if (ap_run_sub_req(rr) == OK) {
+                /* worked... */
+                suppress_sig = 1;
+                suppress_post = suppress_amble;
+            }
+        }
+        else if (!strncasecmp("text/", rr->content_type, 5)) {
+            /*
+             * If we can open the file, suppress the signature.
+             */
+            if (apr_file_open(&f, rr->filename, APR_READ,
+                              APR_OS_DEFAULT, r->pool) == APR_SUCCESS) {
+                do_emit_plain(r, f);
+                apr_file_close(f);
+                suppress_sig = 1;
+            }
+        }
     }

     if (!suppress_sig) {



Mime
View raw message