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 Ivan Prostran <iv...@bulb.hr> on 2012/09/25 13:15:23 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));

Unfortunately, this approach breaks the pipeline because sometimes
the filter needs to buffer data over more than one call, but I do not
consider this as a problem.

or

apr_table_unset(f->r->headers_in, "Content-Length");


Thanks for any help.

Best regards
Ivan

RE: Input filters that alter content-length

Posted by "Mashlum, Samir" <Sa...@adp.com>.
Hi, does anyone knows where I can find an example using apr_crypt API and DES?

Regards,
Sam

----------------------------------------------------------------------
This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, notify the sender immediately by return email and delete the message and any attachments from your system.

Re: Input filters that alter content-length

Posted by Ivan Prostran <iv...@bulb.hr>.
Hi,

I've found one plausible thread that helped me
to understand what's exactly going on here.

[PATCH] Fix proxy's handling of input bodies

http://www.mail-archive.com/dev@httpd.apache.org/msg14091.html

So, if I'm not wrong, the  problemI encountered is
actually related to the proprietary weblogic handler
that, as described in thread, falls if a input filter
changes the content of the original request.

Additional advise on the matter would be appreciated.

I could use mod_proxy, but I don't think
that's possible for the moment :))))

Thanks!

Regards,
Ivan


On 09/26/2012 09:07 PM, Ivan Prostran wrote:
 > On 09/25/12 15:28, Ben Noordhuis wrote:
 >> On Tue, Sep 25, 2012 at 2:51 PM, Ivan Prostran 
<iv...@bulb.hr> wrote:
 >>> Do you suggest chunked transfer encoding?
 >> Yep. There's nary a proxy problem you can't solve with chunked 
encoding.
 >
 > I'm surprised I haven't managed to find example or relevant
 > document/explanation regarding this case.
 >
 > Perhaps I've missed some basic constraints here.
 >
 > I wonder if something like this is supported in the first place.
 >
 > Regards,
 > Ivan


Re: Input filters that alter content-length

Posted by Ivan Prostran <iv...@bulb.hr>.
On 09/25/12 15:28, Ben Noordhuis wrote:
> On Tue, Sep 25, 2012 at 2:51 PM, Ivan Prostran <iv...@bulb.hr> wrote:
>> Do you suggest chunked transfer encoding?
> Yep. There's nary a proxy problem you can't solve with chunked encoding.

I'm surprised I haven't managed to find example or relevant
document/explanation regarding this case.

Perhaps I've missed some basic constraints here.

I wonder if something like this is supported in the first place.

Regards,
Ivan

Re: Input filters that alter content-length

Posted by Ivan Prostran <iv...@gmail.com>.
On 09/25/12 15:28, Ben Noordhuis wrote:
> On Tue, Sep 25, 2012 at 2:51 PM, Ivan Prostran<iv...@bulb.hr>  wrote:
>> Do you suggest chunked transfer encoding?
> Yep. There's nary a proxy problem you can't solve with chunked encoding.

I'm surprised I haven't managed to find example or relevant
document/explanation regarding this case.

Perhaps I've missed some basic constraints here.

I wonder if something like this is supported in the first place.

Regards,
Ivan


Re: Input filters that alter content-length

Posted by Ben Noordhuis <in...@bnoordhuis.nl>.
On Tue, Sep 25, 2012 at 2:51 PM, Ivan Prostran <iv...@bulb.hr> wrote:
> Do you suggest chunked transfer encoding?

Yep. There's nary a proxy problem you can't solve with chunked encoding.

Re: Input filters that alter content-length

Posted by Ivan Prostran <iv...@bulb.hr>.
On 09/25/12 14:04, Ben Noordhuis wrote:
> On Tue, Sep 25, 2012 at 1:15 PM, Ivan Prostran <iv...@bulb.hr> wrote:
>> 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));
>>
>> Unfortunately, this approach breaks the pipeline because sometimes
>> the filter needs to buffer data over more than one call, but I do not
>> consider this as a problem.
>>
>> or
>>
>> apr_table_unset(f->r->headers_in, "Content-Length");
> You didn't tell how your handler works (how it forwards the request)
> but removing the Content-Length header is probably easiest.
To my knowledge this can be done as follows:

    -  When "ap_init_filter_func" callback is invoked
        (before the handler requests data from the client)

     -  within "ap_in_filter_func" callback.

    I tried but it didn't help, infact it didn't work at all.

> Does the
> upstream server understand HTTP/1.1 or HTTP/1.0 with a TE header?

Yes, It understands HTTP/1.1.
Do you suggest chunked transfer encoding?

Thanks for the help.

Best regards,
Ivan


Re: Input filters that alter content-length

Posted by Ben Noordhuis <in...@bnoordhuis.nl>.
On Tue, Sep 25, 2012 at 1:15 PM, Ivan Prostran <iv...@bulb.hr> wrote:
> 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));
>
> Unfortunately, this approach breaks the pipeline because sometimes
> the filter needs to buffer data over more than one call, but I do not
> consider this as a problem.
>
> or
>
> apr_table_unset(f->r->headers_in, "Content-Length");

You didn't tell how your handler works (how it forwards the request)
but removing the Content-Length header is probably easiest. Does the
upstream server understand HTTP/1.1 or HTTP/1.0 with a TE header?