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 Jason Fister <ja...@gmail.com> on 2008/07/17 21:06:25 UTC

ap_get_client_block vs bucket brigades

Hello there,

I have a module thats working as designed and the only reason I am sending
this mail is because I want to confirm what I am doing is the correct way to
do it.

A little background:

We wanted to convert some legacy services to REST webservice. Clients can
upload and retrieve data using this service. So I wrote an apache module
that can be accessed at http://www.mydomain.com/rest/<resource>.

Clients can POST, PUT, GET to this uri. I use ap_get_client_block to read
the http body in case of POST and PUT. I know when we use the
ap_get_client_block method to read the data, the data is not available that
point onwards to any other filter/module and that is totally fine. Thats
because when the uri has '/rest' in it, the data is meant for my module.

I have been doing some online reading and now I am wondering if I shld have
used  buckets/brigades in my module.

1. Is my approach totally wrong?
2. Will the use of bucket brigades have a positive impact on the
performance?

Your help in understanding this issue is much appreciated.


Jason

Re: ap_get_client_block vs bucket brigades

Posted by Jason Fister <ja...@gmail.com>.
On Thu, Jul 17, 2008 at 3:44 PM, Nick Kew <ni...@webthing.com> wrote:

> >        I know when we use the
> > ap_get_client_block method to read the data, the data is not
> > available that point onwards to any other filter/module and that is
> > totally fine. Thats because when the uri has '/rest' in it, the data
> > is meant for my module.
>
>
> That I find confusing.  Mapping /rest/ URLs to your handler should
> be a matter of configuration (cf SetHandler).


Sorry for not being clear. You are correct. I am infact mapping /rest/ to my
module in the config file. What I meant in my earlier mail was that once a
request ends up in my module, the accepted behavior of my module is to
process the data and then return a response to the client. no other
filter/module is supposed to do any further processing of that data.



>
>
> > I have been doing some online reading and now I am wondering if I
> > shld have used  buckets/brigades in my module.
>
> That gives you more flexibility, if you need it.
>
> > 1. Is my approach totally wrong?
> > 2. Will the use of bucket brigades have a positive impact on the
> > performance?
>
> There was talk of deprecating, or even pulling, the client_block API.
> But it never happened, nor do I think it's likely to in future 2.x.
> As for performance, you're unlikely to see a significant change
> unless you find some optimisation outside the scope of this question.
>

Thanks for the clarification!


Jason

Re: ap_get_client_block vs bucket brigades

Posted by Nick Kew <ni...@webthing.com>.
On Thu, 17 Jul 2008 15:06:25 -0400
"Jason Fister" <ja...@gmail.com> wrote:

> Clients can POST, PUT, GET to this uri. I use ap_get_client_block to
> read the http body in case of POST and PUT.

If that works for you, then it's fine.

>	 I know when we use the
> ap_get_client_block method to read the data, the data is not
> available that point onwards to any other filter/module and that is
> totally fine. Thats because when the uri has '/rest' in it, the data
> is meant for my module.

That I find confusing.  Mapping /rest/ URLs to your handler should
be a matter of configuration (cf SetHandler).

> I have been doing some online reading and now I am wondering if I
> shld have used  buckets/brigades in my module.

That gives you more flexibility, if you need it.

> 1. Is my approach totally wrong?
> 2. Will the use of bucket brigades have a positive impact on the
> performance?

There was talk of deprecating, or even pulling, the client_block API.
But it never happened, nor do I think it's likely to in future 2.x.
As for performance, you're unlikely to see a significant change
unless you find some optimisation outside the scope of this question.


-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/

Re: ap_get_client_block vs bucket brigades

Posted by Jason Fister <ja...@gmail.com>.
Sorin,

On Thu, Jul 17, 2008 at 5:52 PM, Sorin Manolache <so...@gmail.com> wrote:

> Just a caveat. Loop like this:
>
> while ((n = ap_get_client_block()) > 0)
>  ...
>
> and not
>
> while (already_read < request->remaining) {
>   n = ap_get_client_block();
>   alread_read += n;
> }
>

Thanks for pointing it out. I am infact looping like ur first example.


>
> request->remaining may be misleading, for example if the client PUSHes
> compressed data request->remaining will indicate the size of the
> compressed data while your module will most likely read the data that
> is already decompressed by the DEFLATE filter on the input filter
> chain.
>
> >  2. Will the use of bucket brigades have a positive impact on the
> >  performance?
>
> Most likely not.
>

Thanks for your help!


Jason

Re: ap_get_client_block vs bucket brigades

Posted by Sorin Manolache <so...@gmail.com>.
On 2008-07-17, Jason Fister <ja...@gmail.com> wrote:
> Hello there,
>
>  I have a module thats working as designed and the only reason I am sending
>  this mail is because I want to confirm what I am doing is the correct way to
>  do it.
>
>  A little background:
>
>  We wanted to convert some legacy services to REST webservice. Clients can
>  upload and retrieve data using this service. So I wrote an apache module
>  that can be accessed at http://www.mydomain.com/rest/<resource>.
>
>  Clients can POST, PUT, GET to this uri. I use ap_get_client_block to read
>  the http body in case of POST and PUT. I know when we use the
>  ap_get_client_block method to read the data, the data is not available that
>  point onwards to any other filter/module and that is totally fine. Thats
>  because when the uri has '/rest' in it, the data is meant for my module.
>
>  I have been doing some online reading and now I am wondering if I shld have
>  used  buckets/brigades in my module.
>
>  1. Is my approach totally wrong?

Just a caveat. Loop like this:

while ((n = ap_get_client_block()) > 0)
 ...

and not

while (already_read < request->remaining) {
   n = ap_get_client_block();
   alread_read += n;
}

request->remaining may be misleading, for example if the client PUSHes
compressed data request->remaining will indicate the size of the
compressed data while your module will most likely read the data that
is already decompressed by the DEFLATE filter on the input filter
chain.

>  2. Will the use of bucket brigades have a positive impact on the
>  performance?

Most likely not.
>
>  Your help in understanding this issue is much appreciated.
>
>
>
>  Jason
>