(sorry for the patches spam / confused proposal) On Wed, Apr 29, 2015 at 6:07 PM, Yann Ylavic <ylavic....@gmail.com> wrote: > We could also avoid the note by setting r->clength = -1 instead in > ap_content_length_filter().
Another candidate could be r->sent_bodyct = 1, eg: Index: server/protocol.c =================================================================== --- server/protocol.c (revision 1676716) +++ server/protocol.c (working copy) @@ -1533,7 +1533,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_content_le * We can only set a C-L in the response header if we haven't already * sent any buckets on to the next output filter for this request. */ - if (ctx->data_sent == 0 && eos && + if (ctx->data_sent == 0 && eos) { /* don't whack the C-L if it has already been set for a HEAD * by something like proxy. the brigade only has an EOS bucket * in this case, making r->bytes_sent zero. @@ -1544,9 +1544,16 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_content_le * such filters update or remove the C-L header, and just use it * if present. */ - !(r->header_only && r->bytes_sent == 0 && - apr_table_get(r->headers_out, "Content-Length"))) { - ap_set_content_length(r, r->bytes_sent); + if (r->header_only && r->bytes_sent == 0 && + apr_table_get(r->headers_out, "Content-Length")) { + /* Tell ap_http_header_filter() we don't want the C-L to + * be stripped (ie. the original no-body is sent now). + */ + r->sent_bodyct = 1; + } + else { + ap_set_content_length(r, r->bytes_sent); + } } ctx->data_sent = 1; Index: modules/http/http_filters.c =================================================================== --- modules/http/http_filters.c (revision 1676716) +++ modules/http/http_filters.c (working copy) @@ -1292,9 +1292,9 @@ 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 - && (clheader = apr_table_get(r->headers_out, "Content-Length")) - && !strcmp(clheader, "0") - && conf->http_cl_head_zero != AP_HTTP_CL_HEAD_ZERO_ENABLE) { + && !r->sent_bodyct + && (clheader = apr_table_get(r->headers_out, "Content-Length")) + && !strcmp(clheader, "0")) { apr_table_unset(r->headers_out, "Content-Length"); } --