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 Jodi Bosa <jo...@gmail.com> on 2011/01/25 23:22:29 UTC
Filter to modify request headers
Hi,
What would be a good early hook to modify request headers that is _AFTER_
mod_ssl is finished decrypting request?
When I do a ap_add_input_filter() from a ap_hook_insert_filter() seems to
trigger really late (e.g. after quick_handler, post_read, etc...).
Ideally, I would prefer working with the simpler request_rec (and headers
tables) but I suspect I need to work with bucket brigades to be able to
change/affect the actual header values for other filters/handlers and so
need to be earlier.
Thanks
Re: Filter to modify request headers
Posted by Nick Kew <ni...@apache.org>.
On 25 Jan 2011, at 22:22, Jodi Bosa wrote:
> Hi,
>
> What would be a good early hook to modify request headers that is _AFTER_
> mod_ssl is finished decrypting request?
>
>
> When I do a ap_add_input_filter() from a ap_hook_insert_filter() seems to
> trigger really late (e.g. after quick_handler, post_read, etc...).
Don't.
Use a header_parser hook to manipulate your request headers.
Or if you need to catch them early, a post_read_request.
--
Nick Kew
Available for work, contract or permanent
http://www.webthing.com/~nick/cv.html
Re: Filter to modify request headers
Posted by Ben Noordhuis <in...@bnoordhuis.nl>.
On Tue, Jan 25, 2011 at 23:22, Jodi Bosa <jo...@gmail.com> wrote:
> What would be a good early hook to modify request headers that is _AFTER_
> mod_ssl is finished decrypting request?
>
> When I do a ap_add_input_filter() from a ap_hook_insert_filter() seems to
> trigger really late (e.g. after quick_handler, post_read, etc...).
post_read is a good place to tamper with headers, it's what mod_headers uses.
Unconditional filters should be registered with
ap_register_input_filter(), conditional filters with
ap_hook_insert_filter() and ap_hook_insert_error_filter()* +
ap_add_input_filter().
mod_ssl's input filter runs at AP_FTYPE_CONNECTION + 5 by the way, so
you're good to go if you hook at AP_FTYPE_CONNECTION + 4. But you
probably don't need to do that.
* Something of a misnomer - error_filter also runs for 204 and 3xx responses.
Re: Filter to modify request headers
Posted by Jodi Bosa <jo...@gmail.com>.
here is another related example:
inside a post_read_request hook, I call ap_add_input_filter() - but it
doesn't execute.
What am I missing?
ap_hook_post_read_request(insert_my_filters, NULL, NULL, APR_HOOK_FIRST);
On Tue, Jan 25, 2011 at 5:22 PM, Jodi Bosa <jo...@gmail.com> wrote:
> Hi,
>
> What would be a good early hook to modify request headers that is _AFTER_
> mod_ssl is finished decrypting request?
>
>
> When I do a ap_add_input_filter() from a ap_hook_insert_filter() seems to
> trigger really late (e.g. after quick_handler, post_read, etc...).
>
>
> Ideally, I would prefer working with the simpler request_rec (and headers
> tables) but I suspect I need to work with bucket brigades to be able to
> change/affect the actual header values for other filters/handlers and so
> need to be earlier.
>
> Thanks
>