[Mod_gzip] mod_gzip and strange vary headers
mod_gzip@lists.over.net
mod_gzip@lists.over.net
Mon, 22 Mar 2004 15:03:49 +0100
Dies ist eine mehrteilige Nachricht im MIME-Format.
--=_alternative 004D45BFC1256E5F_=
Content-Type: text/plain; charset="US-ASCII"
Hi Alpheus,
> hi, I am using mod_gzip 1.3.26.1a and apache 1.3.29.
> if I define rules like
> mod_gzip_item_include reqheader "Accept-Language: en"
> mod_gzip_item_include reqheader "Accept-Charset: dummy"
>
> then I see as the response of the server:
>
> Vary: Accept-Encoding,Accept-Lan,Accept-Cha
>
> it seems as if mod_gzip only includes 10 characters for the the
different
> headers in vary (with exception of accept-encoding).
>
> once I even had a vary header like
> Vary: Accept-Encoding,U
>
> is this a bug or has somebody else encountered the same behaviour.
Although I currently cannot reproduce your effect (the rules do fire
on my server yet they don't have an influence on the "Vary:" header
at all...) I remember to have experienced broken header names in
the "Vary:" header myself before. So I would say this might be a bug,
and if you're using mod_gzip 1.3.26.1a then it seems to be unfixed.
The function that generates this "Vary:" header's content looks like
this (in the mod_gzip 1.3.26.1a I have on my machine):
char *mod_gzip_generate_vary_header(mod_gzip_conf *cfg,struct pool
*p) {
int i = 0;
char name[MOD_GZIP_IMAP_MAXNAMELEN + 2];
array_header *ary =
ap_make_array(p,cfg->imap_total_isreqheader+1,sizeof(char *));
*((const char **)ap_push_array(ary)) =
ap_pstrdup(p,"Accept-Encoding");
for(i=0;i<cfg->imap_total_entries;i++) {
if(cfg->imap[i].type == MOD_GZIP_IMAP_ISREQHEADER) {
mod_gzip_strncpy(name,cfg->imap[i].name,strstr(cfg->imap[i].name,":") -
cfg->imap[i].name - 1);
*((const char **)ap_push_array(ary)) = ap_pstrdup(p,name);
}
}
return ap_array_pstrcat(p,ary,',');
}
The symbolic constant MOD_GZIP_IMAP_MAXNAMELEN is large enough
to hold any HTTP header name (90 characters). But I am not too sure about
this method how to extract the name from the cfg->imap[i] structure.
You can also see that "Accept-Encoding" is added to the "Vary:" string as
a constant (because it will always be a negotiation parameter) while other
headers are taken from the configuration array, so this explains why
"Accept-Encoding" isn't truncated.
Then again, I am not really sure if the problem is located in this
function.
It might be that the directive parser functions already truncate the value
of the HTTP header name in question and this function just copies values.
I tried to set up a debugging environment but don't seem to understand
Christian's debug output mechanism well enough to be able to trace the
directive parsing routines, despite compiling mod_gzip with
-DMOD_GZIP_DEBUG1.
I just haven't seriously used the C language in this millennium any
more... sigh.
Regards, Michael
--=_alternative 004D45BFC1256E5F_=
Content-Type: text/html; charset="US-ASCII"
<br><font size=2 color=red face="sans-serif"><b>Hi Alpheus,</b></font>
<br>
<br>
<br><font size=2 color=red face="sans-serif"><b>> </b></font><font size=2><tt>hi,
I am using mod_gzip 1.3.26.1a and apache 1.3.29.</tt></font>
<br><font size=2 color=red face="sans-serif"><b>> </b></font><font size=2><tt>if
I define rules like</tt></font>
<br><font size=2 color=red face="sans-serif"><b>> </b></font><font size=2><tt>mod_gzip_item_include
reqheader "Accept-Language: en"</tt></font>
<br><font size=2 color=red face="sans-serif"><b>> </b></font><font size=2><tt>mod_gzip_item_include
reqheader "Accept-Charset: dummy"</tt></font>
<br><font size=2 color=red face="sans-serif"><b>></b></font>
<br><font size=2 color=red face="sans-serif"><b>> </b></font><font size=2><tt>then
I see as the response of the server:</tt></font>
<br><font size=2 color=red face="sans-serif"><b>></b></font>
<br><font size=2 color=red face="sans-serif"><b>> </b></font><font size=2><tt>Vary:
Accept-Encoding,Accept-Lan,Accept-Cha</tt></font>
<br><font size=2 color=red face="sans-serif"><b>></b></font>
<br><font size=2 color=red face="sans-serif"><b>> </b></font><font size=2><tt>it
seems as if mod_gzip only includes 10 characters for the the different</tt></font>
<br><font size=2 color=red face="sans-serif"><b>> </b></font><font size=2><tt>headers
in vary (with exception of accept-encoding).</tt></font>
<br><font size=2 color=red face="sans-serif"><b>></b></font>
<br><font size=2 color=red face="sans-serif"><b>> </b></font><font size=2><tt>once
I even had a vary header like</tt></font>
<br><font size=2 color=red face="sans-serif"><b>> </b></font><font size=2><tt>Vary:
Accept-Encoding,U</tt></font>
<br><font size=2 color=red face="sans-serif"><b>></b></font>
<br><font size=2 color=red face="sans-serif"><b>> </b></font><font size=2><tt>is
this a bug or has somebody else encountered the same behaviour.</tt></font>
<br>
<br><font size=2 color=red face="sans-serif"><b>Although I currently cannot
reproduce your effect (the rules do fire</b></font>
<br><font size=2 color=red face="sans-serif"><b>on my server yet they don't
have an influence on the "Vary:" header</b></font>
<br><font size=2 color=red face="sans-serif"><b>at all...) I remember to
have experienced broken header names in</b></font>
<br><font size=2 color=red face="sans-serif"><b>the "Vary:" header
myself before. So I would say this might be a bug,</b></font>
<br><font size=2 color=red face="sans-serif"><b>and if you're using mod_gzip
1.3.26.1a then it seems to be unfixed.</b></font>
<br>
<br>
<br>
<br><font size=2 color=red face="sans-serif"><b>The function that generates
this "Vary:" header's content looks like</b></font>
<br><font size=2 color=red face="sans-serif"><b>this (in the mod_gzip 1.3.26.1a
I have on my machine):</b></font>
<br>
<br><font size=2 color=#800000 face="sans-serif"><b>
char *mod_gzip_generate_vary_header(mod_gzip_conf *cfg,struct
pool *p) {</b></font>
<br><font size=2 color=#800000 face="sans-serif"><b>
int i = 0;</b></font>
<br><font size=2 color=#800000 face="sans-serif"><b>
char name[MOD_GZIP_IMAP_MAXNAMELEN + 2];</b></font>
<br><font size=2 color=#800000 face="sans-serif"><b>
array_header *ary = ap_make_array(p,cfg->imap_total_isreqheader+1,sizeof(char
*));</b></font>
<br>
<br><font size=2 color=#800000 face="sans-serif"><b>
*((const char **)ap_push_array(ary)) = ap_pstrdup(p,"Accept-Encoding");</b></font>
<br>
<br><font size=2 color=#800000 face="sans-serif"><b>
for(i=0;i<cfg->imap_total_entries;i++) {</b></font>
<br><font size=2 color=#800000 face="sans-serif"><b>
if(cfg->imap[i].type == MOD_GZIP_IMAP_ISREQHEADER)
{</b></font>
<br><font size=2 color=#800000 face="sans-serif"><b>
mod_gzip_strncpy(name,cfg->imap[i].name,strstr(cfg->imap[i].name,":")
- cfg->imap[i].name - 1);</b></font>
<br><font size=2 color=#800000 face="sans-serif"><b>
*((const char **)ap_push_array(ary))
= ap_pstrdup(p,name);</b></font>
<br><font size=2 color=#800000 face="sans-serif"><b>
}</b></font>
<br><font size=2 color=#800000 face="sans-serif"><b>
}</b></font>
<br>
<br><font size=2 color=#800000 face="sans-serif"><b>
return ap_array_pstrcat(p,ary,',');</b></font>
<br><font size=2 color=#800000 face="sans-serif"><b>
}</b></font>
<br>
<br><font size=2 color=red face="sans-serif"><b>The symbolic constant MOD_GZIP_IMAP_MAXNAMELEN
is large enough</b></font>
<br><font size=2 color=red face="sans-serif"><b>to hold any HTTP header
name (90 characters). But I am not too sure about</b></font>
<br><font size=2 color=red face="sans-serif"><b>this method how to extract
the name from the cfg->imap[i] structure.</b></font>
<br>
<br><font size=2 color=red face="sans-serif"><b>You can also see that "Accept-Encoding"
is added to the "Vary:" string as</b></font>
<br><font size=2 color=red face="sans-serif"><b>a constant (because it
will always be a negotiation parameter) while other</b></font>
<br><font size=2 color=red face="sans-serif"><b>headers are taken from
the configuration array, so this explains why</b></font>
<br><font size=2 color=red face="sans-serif"><b>"Accept-Encoding"
isn't truncated.</b></font>
<br>
<br><font size=2 color=red face="sans-serif"><b>Then again, I am not really
sure if the problem is located in this function.</b></font>
<br><font size=2 color=red face="sans-serif"><b>It might be that the directive
parser functions already truncate the value</b></font>
<br><font size=2 color=red face="sans-serif"><b>of the HTTP header name
in question and this function just copies values.</b></font>
<br>
<br><font size=2 color=red face="sans-serif"><b>I tried to set up a debugging
environment but don't seem to understand</b></font>
<br><font size=2 color=red face="sans-serif"><b>Christian's debug output
mechanism well enough to be able to trace the</b></font>
<br><font size=2 color=red face="sans-serif"><b>directive parsing routines,
despite compiling mod_gzip with -DMOD_GZIP_DEBUG1.</b></font>
<br><font size=2 color=red face="sans-serif"><b>I just haven't seriously
used the C language in this millennium any more... sigh.</b></font>
<br>
<br><font size=2 color=red face="sans-serif"><b>Regards, Michael</b></font>
--=_alternative 004D45BFC1256E5F_=--