httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sorin Manolache" <>
Subject Re: how to get zipped post data in ap_hook_log_transaction?
Date Tue, 04 Nov 2008 11:24:33 GMT
On Tue, Nov 4, 2008 at 11:46, Andrej van der Zee
<> wrote:
> Hi,
> I was wondering if it is possible to get a hold on the data that is actually
> sent back to the client, preferably in the hook ap_hook_log_transaction. In
> our case we sent back XML data that might be zipped by mod_deflate. If it is
> zipped, I would like to get a hold on the zipped XML data, otherwise the
> unzipped. What would be the best way to do this?

You cannot do it in the log_transaction callback. log_transaction is
called after the socket is flushed, so all filters have been already

Have a look at modules/loggers/mod_logio.c in the apache sources. The
module adds the logio_out_filter as one of the very last filters
(after deflate, just before the filter that performs the actual
writing to the socket). You could write a similar filter that would
record all the bytes that transit your filter. It is quite tricky,
because you need to make the distinction between bytes belonging to
different requests. In order to do that, you need to set a filter

You write something like
ap_register_output_filter(filter_name, filter_function, NULL,
in you module register function.

In filter_function you will write something like
if (flt->ctx == NULL) {
   flt->ctx = (context_type *)apr_pcalloc(request->pool, sizeof(context_type));
// record the bytes that transit. Save them somewhere in the request
pool, see apr_brigade_flatten
// next, pass the data to the next filter in the chain
return ap_pass_brigade(flt->next, bb);

Then, in log_transaction you'll recover it from where you put it aside.

You need to add SetOutputFilter filter_name in your apache config.

However, I think the best way to do this would be with network
sniffers (tcpdump, wireshark), not with apache.


View raw message