]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Apply a fix already in Apache 2.0 (and add quality weights) to prevent
authorWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 18 Dec 2002 22:27:54 +0000 (22:27 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 18 Dec 2002 22:27:54 +0000 (22:27 +0000)
  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

src/modules/standard/mod_autoindex.c

index 34ba9a978d9a6597431dc8dbc9da5536fd530959..fa86303c2149daa06f4b9cbe34d04eb0331fec6b 100644 (file)
@@ -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);
     }