From: William A. Rowe Jr Date: Wed, 18 Dec 2002 22:27:54 +0000 (+0000) Subject: Apply a fix already in Apache 2.0 (and add quality weights) to prevent X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e349f047201e9db3af9ad840633fc579d460981c;p=thirdparty%2Fapache%2Fhttpd.git Apply a fix already in Apache 2.0 (and add quality weights) to prevent us from attempting to serve .gif or any other flavor of negotiated resources. This patch fixes the Accept: header of the autoindex request so that it's subrequests look for text/ only, with weights applied to recover .html, then .txt, then some other flavor of text/* in their absense. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@98032 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/modules/standard/mod_autoindex.c b/src/modules/standard/mod_autoindex.c index 34ba9a978d9..fa86303c214 100644 --- a/src/modules/standard/mod_autoindex.c +++ b/src/modules/standard/mod_autoindex.c @@ -1000,6 +1000,18 @@ static void emit_head(request_rec *r, char *header_fname, int suppress_amble, request_rec *rr = NULL; int emit_amble = 1; int emit_H1 = 1; + const char *r_accept; + const char *r_accept_enc; + table *hdrs = r->headers_in; + + /* + * If there's a header file, send a subrequest to look for it. If it's + * found and html do the subrequest, otherwise handle it + */ + r_accept = ap_table_get(hdrs, "Accept"); + r_accept_enc = ap_table_get(hdrs, "Accept-Encoding"); + ap_table_setn(hdrs, "Accept", "text/html, text/plain;q=.5, text/*;q=.1"); + ap_table_unset(hdrs, "Accept-Encoding"); /* * If there's a header file, send a subrequest to look for it. If it's @@ -1061,6 +1073,17 @@ static void emit_head(request_rec *r, char *header_fname, int suppress_amble, } } + if (r_accept) { + ap_table_setn(hdrs, "Accept", r_accept); + } + else { + ap_table_unset(hdrs, "Accept"); + } + + if (r_accept_enc) { + ap_table_setn(hdrs, "Accept-Encoding", r_accept_enc); + } + if (emit_amble) { emit_preamble(r, title); } @@ -1088,6 +1111,18 @@ static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble) request_rec *rr = NULL; int suppress_post = 0; int suppress_sig = 0; + const char *r_accept; + const char *r_accept_enc; + table *hdrs = r->headers_in; + + /* + * If there's a readme file, send a subrequest to look for it. If it's + * found and html do the subrequest, otherwise handle it + */ + r_accept = ap_table_get(hdrs, "Accept"); + r_accept_enc = ap_table_get(hdrs, "Accept-Encoding"); + ap_table_setn(hdrs, "Accept", "text/html, text/plain;q=.5, text/*;q=.1"); + ap_table_unset(hdrs, "Accept-Encoding"); /* * If there's a readme file, send a subrequest to look for it. If it's @@ -1132,6 +1167,17 @@ static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble) } } + if (r_accept) { + ap_table_setn(hdrs, "Accept", r_accept); + } + else { + ap_table_unset(hdrs, "Accept"); + } + + if (r_accept_enc) { + ap_table_setn(hdrs, "Accept-Encoding", r_accept_enc); + } + if (!suppress_sig) { ap_rputs(ap_psignature("", r), r); }