Roy T. Fielding wrote:
On Oct 19, 2005, at 8:35 AM, Greg Ames wrote:
let's say it is a HEAD request for a local static file. the
default_handler calls ap_set_content_length which creates a C-L
header. but then the body could be run through some length changing
filter, such as mod_deflate or mod_include, invalidating the
default_handler's C-L.
Then that filter must remove or modify the C-L.
in that case we want to update the C-L to reflect what's currently in
the brigade. so we need to behave differently when there is no body
at all, like proxy, and when there is a temporary body which will be
thrown away shortly.
That sounds like spaghetti code to me. Fix the bug in the filters,
not the side-effects.
I think that's a good philosophy. unfortunately, if I read the only developer doc I can
find on Apache filters http://httpd.apache.org/docs/2.0/developer/filters.html I don't see
any rules about what to do when your filter changes the length of the body.
I believe ap_content_length_filter was intended to be the magic that allowed filter
developers to ignore the C-L header but maybe the magic is more trouble than it's worth.
it would be much cleaner to do as you suggest and also change the C-L filter to be a no-op
when a C-L header is already present. that is potentially disruptive to the stable
release, perhaps not a big deal in trunk.
+1 on this patch as a temporary fix if you add commentary with it,
but I'd rather have a server that isn't so fragile in the long term.
thanks and agreed.
Greg