Hracek, Petr wrote:

Because of I am a begginer with bucket and brigades
Is there any short example how to send simple string to the client?
I've found some examples but it were a pretty complicated for me.

E.g. http://www.apachetutor.org/dev/brigades

Go through the underlying bucket brigade API here:

http://apr.apache.org/docs/apr-util/trunk/group___a_p_r___util___bucket___brigades.html

Essentially from your perspective, you want to create a brigade with apr_brigade_create(), and then create buckets, and put those buckets into the brigade.

When you want to flush the data, create a flush bucket, add it to the brigade, and give the brigade to the network using ap_pass_brigade(). You can call ap_pass_brigade as many times as you like (calling it excessively is inefficient though).

To create a flush bucket, use apr_bucket_flush_create.

There are convenience functions that allow you to add strings to a bucket brigade without having to create buckets from scratch:

apr_brigade_write
apr_brigade_writev
apr_brigade_printf
...etc

A note about what a bucket brigade is: a bucket_brigade is basically a linked list of pieces of data.

"Pieces of data" can be quite broad a definition. A piece of data might be a simple string, stored in a heap bucket. A "piece of data" might be a file on disk, stored in a file bucket.

The "piece of data" can also not be data at all, but rather a signal to do something special. A flush bucket is one example, and the EOS (end-of-stream) bucket is another that says "this is the last bucket in this response, you're done now".

The bucket brigade API is a bit mind bending at first, but it is a very valuable tool to use. If you want to write an Apache v2 filter, you'll need to know how the bucket brigades work, so they are definitely worth getting to understand.

Regards,
Graham
--

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to