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 Marco Spinetti <m....@pisa.iol.it> on 2007/07/03 17:18:44 UTC
using mod_deflate inside a module
I have a question about how to use a part of mod_deflate in my module.
Inside my module I connect to a external source sending it a dynamic
query and it replies with a gzip content.
I should take this content, decompress it and then I have to modify it.
I'd like to know if inside my module I could call the function inside
mod_deflate to decompress the content.
Can I do it?
Best regards
Marco
Re: using mod_deflate inside a module
Posted by Nick Kew <ni...@webthing.com>.
On Wed, 04 Jul 2007 17:38:20 +0200
Marco Spinetti <m....@pisa.iol.it> wrote:
> Nick, could you advice me with a solution
See the first sentence of the second paragraph of what I posted:
> > If you want a functional API for (de)compression, then nothing in
> > apache is relevant to you, except insofar as the mod_deflate code
> > is a usage example.
--
Nick Kew
Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/
Re: using mod_deflate inside a module
Posted by Marco Spinetti <m....@pisa.iol.it>.
Well my architecture now is a module which gets the contents from
different sources, elaborate them building a final xml and then it
registers an output filter which reply to the user.
So I'm already using an output filter.
But if only a source of mine reply with gzip content, I don't see how to
pass it to mod_deflate, which decompresses it, and then elaborate it
with the other sources.
Nick, could you advice me with a solution (the only solution I'm seeing
now is write a function to decompress the content but I'd like to use
the one given by mod_deflate).
Nick Kew ha scritto:
> On Wed, 04 Jul 2007 17:08:56 +0200
> Marco Spinetti <m....@pisa.iol.it> wrote:
>
>
>> There is something I can't understand.
>> If you declare
>>
>> ap_add_output_filter("INFLATE", ctx, req, conn);
>>
>> how can I call the function to decompress a content and the get the
>> control again?
>> I knew that ap_add_output_filter declares an outut filter which is
>> called after your module.
>> Am I missing something?
>>
>
> It sounds like you're missing apache's filter architecture. It's too
> much to summarise in an email, but see my .sig (the site has articles
> as well as the book). The manpage for mod_filter might also help
> explain what Mike tried to tell you.
>
> If you want a functional API for (de)compression, then nothing in
> apache is relevant to you, except insofar as the mod_deflate code
> is a usage example. Of course you can do that: you just lose the
> benefits of Apache's modular architecture, and end up with something
> looking like a monolithic kitchen-sink CGI application.
>
>
Re: using mod_deflate inside a module
Posted by Nick Kew <ni...@webthing.com>.
On Wed, 04 Jul 2007 17:08:56 +0200
Marco Spinetti <m....@pisa.iol.it> wrote:
> There is something I can't understand.
> If you declare
>
> ap_add_output_filter("INFLATE", ctx, req, conn);
>
> how can I call the function to decompress a content and the get the
> control again?
> I knew that ap_add_output_filter declares an outut filter which is
> called after your module.
> Am I missing something?
It sounds like you're missing apache's filter architecture. It's too
much to summarise in an email, but see my .sig (the site has articles
as well as the book). The manpage for mod_filter might also help
explain what Mike tried to tell you.
If you want a functional API for (de)compression, then nothing in
apache is relevant to you, except insofar as the mod_deflate code
is a usage example. Of course you can do that: you just lose the
benefits of Apache's modular architecture, and end up with something
looking like a monolithic kitchen-sink CGI application.
--
Nick Kew
Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/
Re: using mod_deflate inside a module
Posted by Marco Spinetti <m....@pisa.iol.it>.
There is something I can't understand.
If you declare
ap_add_output_filter("INFLATE", ctx, req, conn);
how can I call the function to decompress a content and the get the
control again?
I knew that ap_add_output_filter declares an outut filter which is
called after your module.
Am I missing something?
Mike ha scritto:
> On 7/4/07, Marco Spinetti <m....@pisa.iol.it> wrote:
>> So are you telling me that I should call deflate_in_filter (which is
>> defined inside mod_defalte) inside my module and then go on with the
>> uncompressed result?
>> Could you give me some suggestion about how to do it?
> you need to include mod_deflate in config:
> LoadModule mod_deflate....
>
> then in function where you call hooks you need to put this function:
> ap_add_output_filter("INFLATE", ctx, req, conn);
>
> and you'll have inflate filter right before your own. chekc docs for
> proper usage and parameters.
>
> module my_module = {
> STANDARD20_MODULE_STUFF,
> my_create_dir_conf, /* Create config rec for Directory */
> my_merge_dir_conf, /* Merge config rec for Directory */
> my_create_svr_conf, /* Create config rec for Host */
> my_merge_svr_conf, /* Merge config rec for Host */
> my_cmds, /* Configuration directives */
> my_hooks <--- add ap_add... function call into body of this function...
> } ;
>
> Kind regards.
>
Re: using mod_deflate inside a module
Posted by Mike <dy...@gmail.com>.
On 7/4/07, Marco Spinetti <m....@pisa.iol.it> wrote:
> So are you telling me that I should call deflate_in_filter (which is
> defined inside mod_defalte) inside my module and then go on with the
> uncompressed result?
> Could you give me some suggestion about how to do it?
you need to include mod_deflate in config:
LoadModule mod_deflate....
then in function where you call hooks you need to put this function:
ap_add_output_filter("INFLATE", ctx, req, conn);
and you'll have inflate filter right before your own. chekc docs for
proper usage and parameters.
module my_module = {
STANDARD20_MODULE_STUFF,
my_create_dir_conf, /* Create config rec for Directory */
my_merge_dir_conf, /* Merge config rec for Directory */
my_create_svr_conf, /* Create config rec for Host */
my_merge_svr_conf, /* Merge config rec for Host */
my_cmds, /* Configuration directives */
my_hooks <--- add ap_add... function call into body of this function...
} ;
Kind regards.
Re: using mod_deflate inside a module
Posted by Marco Spinetti <m....@pisa.iol.it>.
So are you telling me that I should call deflate_in_filter (which is
defined inside mod_defalte) inside my module and then go on with the
uncompressed result?
Could you give me some suggestion about how to do it?
Best regards
Mike ha scritto:
> On Tue, Jul 03, 2007 at 05:18:44PM +0200, Marco Spinetti wrote:
>
>> I have a question about how to use a part of mod_deflate in my module.
>> Inside my module I connect to a external source sending it a dynamic query
>> and it replies with a gzip content.
>> I should take this content, decompress it and then I have to modify it.
>> I'd like to know if inside my module I could call the function inside
>> mod_deflate to decompress the content.
>> Can I do it?
>>
> Yes, you do. You can attach DEFLATE or INFLATE filter in your module provided
> mod_deflate is loaded.
>
> Somewhere near the hooks' definition you should put:
> add_output_filter("INFLATE") or smth. Please consult the Apache docs for
> details.
>
>
Re: using mod_deflate inside a module
Posted by Mike <dy...@gmail.com>.
On Tue, Jul 03, 2007 at 05:18:44PM +0200, Marco Spinetti wrote:
> I have a question about how to use a part of mod_deflate in my module.
> Inside my module I connect to a external source sending it a dynamic query
> and it replies with a gzip content.
> I should take this content, decompress it and then I have to modify it.
> I'd like to know if inside my module I could call the function inside
> mod_deflate to decompress the content.
> Can I do it?
Yes, you do. You can attach DEFLATE or INFLATE filter in your module provided
mod_deflate is loaded.
Somewhere near the hooks' definition you should put:
add_output_filter("INFLATE") or smth. Please consult the Apache docs for
details.