You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2002/12/18 23:27:55 UTC
cvs commit: apache-1.3/src/modules/standard mod_autoindex.c
wrowe 2002/12/18 14:27:55
Modified: src/modules/standard mod_autoindex.c
Log:
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.
Revision Changes Path
1.124 +46 -0 apache-1.3/src/modules/standard/mod_autoindex.c
Index: mod_autoindex.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_autoindex.c,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -r1.123 -r1.124
--- mod_autoindex.c 13 Mar 2002 21:05:33 -0000 1.123
+++ mod_autoindex.c 18 Dec 2002 22:27:54 -0000 1.124
@@ -1000,6 +1000,18 @@
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 @@
}
}
+ 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 @@
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 @@
}
}
+ 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);
}
Re: cvs commit: apache-1.3/src/modules/standard mod_autoindex.c
Posted by André Malo <nd...@perlig.de>.
* William A. Rowe, Jr. wrote:
> The request headers_in are only modified for the duration of
> looking up the potential subrequests.
>
> So I'm confused why (for that brief time) it has been messing
> up mod_deflate's filter?
mod_autoindex.c (2.1) line 1000 removes the accept-encoding.
Then it does the sub_req_uri_lookup, if ok, it runs either ap_run_sub_req
or do_emit_plain. If I understand it correctly, both put already data onto
to filter stack.
And *after* the first data (i.e. the header file) is emitted, mod_autoindex
re-adds the accept-encoding. That seems to be too late for mod_deflate.
the conclusion is:
AddOutputFilterByType DEFLATE httpd/unix-directory
doesn't work in the case, HeaderName is used (in my tests).
nd
--
die (eval q-qq[Just Another Perl Hacker
]
;-)
# André Malo, <http://www.perlig.de/> #
Re: cvs commit: apache-1.3/src/modules/standard mod_autoindex.c
Posted by "William A. Rowe, Jr." <wr...@apache.org>.
The request headers_in are only modified for the duration of
looking up the potential subrequests.
So I'm confused why (for that brief time) it has been messing
up mod_deflate's filter?
Bill
At 04:51 PM 12/18/2002, André Malo wrote:
>* wrowe@apache.org wrote:
>
>> + /*
>> + * 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");
>
>by the way. In 1.3 it's perhaps not interesting, but in 2.x this causes the
>problem, that mod_deflate won't be invoked, if a HeaderName file will be
>inserted. We delete the Accept-Encoding header, put the contents of the
>header file onto the filter stack, mod_deflate doesn't recognize an
>accepted encoding, it removes itself from the stack, we re-add the
>Accept-Encoding, now it's too late.
>
>However, is there no possibility to modify the accept values only for the
>subrequest?
>
>nd
>--
>> [...] weiß jemand zufällig, was der Tag DIV ausgeschrieben bedeutet?
>DIVerses. Benannt nach all dem unstrukturierten Zeug, was die Leute da
>so reinpacken und dann absolut positionieren ...
> -- Florian Hartig und Lars Kasper in dciwam
Re: cvs commit: apache-1.3/src/modules/standard mod_autoindex.c
Posted by André Malo <nd...@perlig.de>.
* wrowe@apache.org wrote:
> + /*
> + * 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");
by the way. In 1.3 it's perhaps not interesting, but in 2.x this causes the
problem, that mod_deflate won't be invoked, if a HeaderName file will be
inserted. We delete the Accept-Encoding header, put the contents of the
header file onto the filter stack, mod_deflate doesn't recognize an
accepted encoding, it removes itself from the stack, we re-add the
Accept-Encoding, now it's too late.
However, is there no possibility to modify the accept values only for the
subrequest?
nd
--
> [...] weiß jemand zufällig, was der Tag DIV ausgeschrieben bedeutet?
DIVerses. Benannt nach all dem unstrukturierten Zeug, was die Leute da
so reinpacken und dann absolut positionieren ...
-- Florian Hartig und Lars Kasper in dciwam