httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "José Muanis" <mua...@gmail.com>
Subject Help with input filter ... crashing apache ...
Date Wed, 09 Aug 2006 15:21:52 GMT
Hi, hope that someone has any time to help me.

I'm designing an input filter, my goal is to parse de URI and Cookies,
set a couple of new headers in the request and change the uri.

I have coded some stuff, based on Ryan Bloom article 'Writing Input
Filters for Apache 2.0'
(http://www.onlamp.com/pub/a/apache/2001/09/20/apache_2.html).

Right now, I managed to deal with the buckets to change the uri. At
the end of the code, I get the first bucket in the brigade, and it
looks fine (from my  point of view of course).

What I've done is the following:

First of all, I register the following hooks:

ap_hook_pre_connection(headers_pre, NULL, NULL, APR_HOOK_MIDDLE);
ap_register_input_filter("HEADERS_IN", headers_filter_in,
NULL,AP_FTYPE_CONNECTION);

On headers_pre I do the following:

ap_add_input_filter("HEADERS_IN", NULL, NULL, c);

I'm adding this stuff because maybe you will tell me "You should not
use this type of filter to do this".

On header_filters in, i get the brigade, get the first bucket, cut
everything, just like in the article.

At the end of the code (again, just like in the article) I do the following:

d = apr_bucket_transient_create(data, 23, bb->bucket_alloc);
apr_bucket_setaside(d, f->c->pool);

APR_BUCKET_INSERT_AFTER(e, d);
APR_BUCKET_REMOVE(e);
apr_bucket_destroy(e);

return APR_SUCCESS;

If I remove the line where I insert the new bucket (d) after (e) the
code executes and apache don't crash (but I get an error, as bucket
(e) does not contain a uri. When I insertthe line with the insert
after, I crash apache.

As an info I'm coding and testing it on Windows XP, with VStudio.
(Please, don't blame on me I should be using unix for it).

Thanks in advance,

Jose Muanis

Mime
View raw message