Due to ap_http_header_filter(): /* This is a hack, but I can't find anyway around it. The idea is that * we don't want to send out 0 Content-Lengths if it is a head request. * This happens when modules try to outsmart the server, and return * if they see a HEAD request. Apache 1.3 handlers were supposed to * just return in that situation, and the core handled the HEAD. In * 2.0, if a handler returns, then the core sends an EOS bucket down * the filter stack, and the content-length filter computes a C-L of * zero and that gets put in the headers, and we end up sending a * zero C-L to the client. We can't just remove the C-L filter, * because well behaved 2.0 handlers will send their data down the stack, * and we will compute a real C-L for the head request. RBB * * Allow modification of this behavior through the * HttpContentLengthHeadZero directive. * * The default (unset) behavior is to squelch the C-L in this case. */ if (r->header_only && (clheader = apr_table_get(r->headers_out, "Content-Length")) && !strcmp(clheader, "0") && conf->http_cl_head_zero != AP_HTTP_CL_HEAD_ZERO_ENABLE) { apr_table_unset(r->headers_out, "Content-Length"); }
I find this workaround a bit too much hacky because "Content-Length: 0" could be the real one for the corresponding GET request, either given by a module or forwarded from a backend. Hence how about removing this whole block (is there any module today "outsmarting" httpd that cannot be considered as buggy?) or least disable it for forwarded responses, eg: Index: modules/http/http_filters.c =================================================================== --- modules/http/http_filters.c (revision 1676716) +++ modules/http/http_filters.c (working copy) @@ -1292,6 +1292,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_heade * The default (unset) behavior is to squelch the C-L in this case. */ if (r->header_only + && !r->proxyreq && (clheader = apr_table_get(r->headers_out, "Content-Length")) && !strcmp(clheader, "0") && conf->http_cl_head_zero != AP_HTTP_CL_HEAD_ZERO_ENABLE) { -- ?