How to do a sub-request from input filter?
Hi, I am using Apache as a reverse proxy to forward requests to a backend web server protected by some self-written Apache modules. Now I would like to do a sub-request to a different location from within an input filter. What is the easiest way to achieve this? Reading Nick Kew's excellent Apache Modules Book I've found the function ap_internal_redirect(), but does this function also work from an input filter? Currently I doubt it because the first line of the HTTP request for the backend web server is built very early in ap_proxy_http_request(), apparently before running the input filters... Do you have any better suggestion? What else should I keep in mind in this situation? Regards, Micha
Re: How to do a sub-request from input filter?
On 27 Apr 2011, at 18:07, Micha Lenk wrote: > What else should I keep in mind in this situation? You may be a little confused. Subrquests and internal redirects are not the same thing, and serve different purposes. Maybe the book, which discusses them in consecutive sections in the chapter on the request processing cycle, should be clearer. A subrequest should be OK in a filter, but if it generates any output you'd need to figure out where to send it - which is not obvious in an input filter. As for an internal redirect, I don't see how it would make sense, but I haven't tried. BTW, this would be better on the modules-dev list. -- Nick Kew Available for work, contract or permanent http://www.webthing.com/~nick/cv.html
Re: How to do a sub-request from input filter?
On 27 Apr 2011, at 7:07 PM, Micha Lenk wrote: I am using Apache as a reverse proxy to forward requests to a backend web server protected by some self-written Apache modules. Now I would like to do a sub-request to a different location from within an input filter. What is the easiest way to achieve this? Reading Nick Kew's excellent Apache Modules Book I've found the function ap_internal_redirect(), but does this function also work from an input filter? Currently I doubt it because the first line of the HTTP request for the backend web server is built very early in ap_proxy_http_request(), apparently before running the input filters... Do you have any better suggestion? What else should I keep in mind in this situation? It depends, do you want the subrequest to replace the main request? Or do you want the subrequest to happen, and then for the main request to continue as it was before? Regards, Graham --
Re: How to do a sub-request from input filter?
Hi Graham, On Wed, Apr 27, 2011 at 07:44:05PM +0200, Graham Leggett wrote: > On 27 Apr 2011, at 7:07 PM, Micha Lenk wrote: > >I am using Apache as a reverse proxy to forward requests to a backend web > >server protected by some self-written Apache modules. Now I would like to > >do a sub-request to a different location from within an input filter. > > > >What is the easiest way to achieve this? Reading Nick Kew's excellent > >Apache Modules Book I've found the function ap_internal_redirect(), but > >does this function also work from an input filter? Currently I doubt it > >because the first line of the HTTP request for the backend web server is > >built very early in ap_proxy_http_request(), apparently before running > >the input filters... > >Do you have any better suggestion? > > > >What else should I keep in mind in this situation? > > It depends, do you want the subrequest to replace the main request? > Or do you want the subrequest to happen, and then for the main > request to continue as it was before? I want the subrequest to replace the main request. Regards, Micha