This is a wee bit to hackish.  Proper configuration of the files is more
appropriate.  On Apache 1.3, I believe the hack that works is

AddType /README text/plain
AddType /HEADER text/plain

Please don't ask why this should work ... is just does ;)

Give it a shot, let us know if it solves your problem without hassle.

Bill

----- Original Message ----- 
From: "Robert Simonson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 29, 2001 8:41 AM
Subject: [PATCH] mod_autoindex HeaderName/ReadmeName content_type


> This patch is to set the content_type to the default if the subrequest
> request_rec content_type is NULL.
> 
> Rob Simonson
> [EMAIL PROTECTED]
> 
> ==========================================================
> --- 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) {
> 
> 
> 

Reply via email to