You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Pechoultres Xavier <x....@clariprint.fr> on 2015/12/09 15:02:28 UTC

Apache add content-length

Hi everybody,

	I wrote an apache (2.2.x) module for special c++ app. It works fine for many years but a problem resist to me.

Apache automatically add a content-length header even I send a Transfer-Encoding: chunked

I set Transfer-Encoding: chunked in cgi module, I’m sure I do not set a content-length here.
I unset Content-length in my module :  apr_table_unset(r->headers_out, "Content-Length »);

I’ve tried lot of stuff without success, and Apache always add a content-length. This create bug with recent WebCore application.

If somebody can give me the light !

Thanks to read me,

Xavier



Re: Apache add content-length

Posted by Sorin Manolache <so...@gmail.com>.
On 2015-12-09 15:02, Pechoultres Xavier wrote:
> Hi everybody,
>
> 	I wrote an apache (2.2.x) module for special c++ app. It works fine for many years but a problem resist to me.
>
> Apache automatically add a content-length header even I send a Transfer-Encoding: chunked
>
> I set Transfer-Encoding: chunked in cgi module, I’m sure I do not set a content-length here.
> I unset Content-length in my module :  apr_table_unset(r->headers_out, "Content-Length »);
>
> I’ve tried lot of stuff without success, and Apache always add a content-length. This create bug with recent WebCore application.
>
> If somebody can give me the light !

I've checked the sources of the apache server. Apache adds some filters 
to the request processing chain, two of them being 
ap_content_length_filter and ap_http_header_filter. 
ap_content_length_filter executes before ap_http_header_filter.

ap_content_length_filter sets the Content-Length header if it can 
determine the size of the response body. ap_http_header_filter sets 
r->chunked only if the Content-Length header is not set. The response is 
chunked and the "Transfer-Encoding: chunked" header is set only if 
r->chunked = 1.

In short: if apache can determine the size of the response message then 
you cannot force it to send "Transfer-Encoding: chunked" and it will 
always set the Content-Length header.

--
Sorin