You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Ivan Prostran <iv...@bulb.hr> on 2012/09/21 12:41:44 UTC
Input filters that alter content-length
Hi,
I have the following scenario :
- Apache/2.2.19 (Solaris 10 SPARC)
SetInputFilter alterxmlbody (AP_FTYPE_RESOURCE)
SetHandler weblogic-handler
The handler forwards requests to multiple weblogic servers
and the filter itself analyzes and/or changes the POST data
in a way that the length of the incoming request may be changed.
The question is :
What is the proper and legitimate way to deal with this situation?
Should the input filter set the new CL value in "headers_in" before
returning from the callback, or just remove it from the list?
apr_off_t length;
apr_brigade_length (bb,1,&length);
apr_table_setn(f->r->headers_in, "Content-Length",
apr_off_t_toa(f->r->pool, length));
or
apr_table_unset(f->r->headers_in, "Content-Length");
Best regards
Ivan
Re: Input filters that alter content-length
Posted by Ivan Prostran <iv...@bulb.hr>.
Hi,
Thanks for your prompt response.
Regards,
Ivan
On 09/21/12 13:05, Graham Leggett wrote:
> On 21 Sep 2012, at 12:41 PM, Ivan Prostran <iv...@bulb.hr> wrote:
>
>> I have the following scenario :
>>
>> - Apache/2.2.19 (Solaris 10 SPARC)
>>
>> SetInputFilter alterxmlbody (AP_FTYPE_RESOURCE)
>> SetHandler weblogic-handler
> First off, the users@httpd.apache.org list is a better place for this, this is the APR list.
>
>> The handler forwards requests to multiple weblogic servers
>> and the filter itself analyzes and/or changes the POST data
>> in a way that the length of the incoming request may be changed.
>>
>> The question is :
>>
>> What is the proper and legitimate way to deal with this situation?
>>
>> Should the input filter set the new CL value in "headers_in" before
>> returning from the callback, or just remove it from the list?
>>
>> apr_off_t length;
>> apr_brigade_length (bb,1,&length);
>> apr_table_setn(f->r->headers_in, "Content-Length", apr_off_t_toa(f->r->pool, length));
> This is definitely wrong - a filter can expect to be called multiple times, the above code assumes you'll be called once.
>
>> or
>>
>> apr_table_unset(f->r->headers_in, "Content-Length");
> This is the simplest way to do it, a further filter inside httpd will put Content-Length back if practical.
>
> Look in the httpd source for examples on how filters handle this kind of thing.
>
> Regards,
> Graham
> --
>
Re: Input filters that alter content-length
Posted by Graham Leggett <mi...@sharp.fm>.
On 21 Sep 2012, at 12:41 PM, Ivan Prostran <iv...@bulb.hr> wrote:
> I have the following scenario :
>
> - Apache/2.2.19 (Solaris 10 SPARC)
>
> SetInputFilter alterxmlbody (AP_FTYPE_RESOURCE)
> SetHandler weblogic-handler
First off, the users@httpd.apache.org list is a better place for this, this is the APR list.
> The handler forwards requests to multiple weblogic servers
> and the filter itself analyzes and/or changes the POST data
> in a way that the length of the incoming request may be changed.
>
> The question is :
>
> What is the proper and legitimate way to deal with this situation?
>
> Should the input filter set the new CL value in "headers_in" before
> returning from the callback, or just remove it from the list?
>
> apr_off_t length;
> apr_brigade_length (bb,1,&length);
> apr_table_setn(f->r->headers_in, "Content-Length", apr_off_t_toa(f->r->pool, length));
This is definitely wrong - a filter can expect to be called multiple times, the above code assumes you'll be called once.
> or
>
> apr_table_unset(f->r->headers_in, "Content-Length");
This is the simplest way to do it, a further filter inside httpd will put Content-Length back if practical.
Look in the httpd source for examples on how filters handle this kind of thing.
Regards,
Graham
--