You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Micha Lenk <mi...@lenk.info> on 2011/04/28 18:38:00 UTC

Re: How to do a internal redirect (was: sub-request) from input filter?

Hi Nick,

On Wed, Apr 27, 2011 at 06:39:49PM +0100, Nick Kew wrote:
> You may be a little confused.  Subrquests and internal redirects
> are not the same thing, and serve different purposes. [...]

You're right, what I want is an internal redirect from within my input filter,
not a subrequest.

> 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.

I've just tried it with ap_internal_redirect(), and the redirected request
indeed gets processed almost as intended. I've still following issues with this
approach:

1.) Additional to the redirected request, the original request ends up at the
backend server too. Only if I return from the input filter with something
non-zero, the request doesn't reach the backend server. But in this case a
"proxy: prefetch request body failed "... error is logged by
ap_proxy_http_request(). From reading the whole code of ap_proxy_http_request()
I wonder whether internal redirects calling what ever redirect function from
input filters are supported at all.

2.) The redirected request seems to inherit the request method from the
originial request. This is not what I want. The input filter operates on the
request body of a POST request, but the internal redirection should do a GET
request.

What else do you suggest?
Should I parse the request body in a content handler instead inside an input
filter?

Thanks in advance for your feedback.

Regards,
Micha

Re: How to do a internal redirect

Posted by Ruediger Pluem <rp...@apache.org>.

On 04/28/2011 06:38 PM, Micha Lenk wrote:
> Hi Nick,
> 
> On Wed, Apr 27, 2011 at 06:39:49PM +0100, Nick Kew wrote:
>> You may be a little confused.  Subrquests and internal redirects
>> are not the same thing, and serve different purposes. [...]
> 
> You're right, what I want is an internal redirect from within my input filter,
> not a subrequest.
> 
>> 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.
> 
> I've just tried it with ap_internal_redirect(), and the redirected request
> indeed gets processed almost as intended. I've still following issues with this
> approach:
> 
> 1.) Additional to the redirected request, the original request ends up at the
> backend server too. Only if I return from the input filter with something
> non-zero, the request doesn't reach the backend server. But in this case a
> "proxy: prefetch request body failed "... error is logged by
> ap_proxy_http_request(). From reading the whole code of ap_proxy_http_request()
> I wonder whether internal redirects calling what ever redirect function from
> input filters are supported at all.
> 
> 2.) The redirected request seems to inherit the request method from the
> originial request. This is not what I want. The input filter operates on the
> request body of a POST request, but the internal redirection should do a GET
> request.
> 
> What else do you suggest?
> Should I parse the request body in a content handler instead inside an input
> filter?

That sounds like a better idea. The input filter comes too late as the proxy
module already started processing the request at this point of time.
So IMHO you should use either process your data in a handler or in the fixup hook.
Maybe a look to mod_dir (the module that does internal redirects like / -> /index.html)
is helpful.

Regards

RĂ¼diger