On Monday 26 March 2007 16:57, Perrin Harkins wrote:
> On 3/26/07, Anthony Gardner <[EMAIL PROTECTED]> wrote:
> > Can I only use internal_redirect in handlers or is it possible to use it
> > within a cgi script calling another cgi script?
>
> If by "CGI script" you mean something running ModPerl::Registry, then
> yes, it works fine.  If you mean a perl program called through mod_cgi
> and not mod_perl, then no.  You would have to fake that with LWP or
> similar.

Not entirely true, a CGI script (mod_cgid?) can generate an internal redirect 
saying

Status: 200
Location: /path/to/other.html

Both mod_cgi and mod_cgid contain this code:

        if (location && location[0] == '/' && r->status == 200) {
            /* This redirect needs to be a GET no matter what the original
             * method was.
             */
            r->method = apr_pstrdup(r->pool, "GET");
            r->method_number = M_GET;

            /* We already read the message body (if any), so don't allow
             * the redirected request to think it has one.  We can ignore
             * Transfer-Encoding, since we used REQUEST_CHUNKED_ERROR.
             */
            apr_table_unset(r->headers_in, "Content-Length");

            ap_internal_redirect_handler(location, r);
            return OK;
        }

As for Modperl::Registry, you need to use the perl-script handler and enable 
PerlOptions +ParseHeaders. Then the same approach works also for Registry 
scripts, see modperl_cgi.c:modperl_cgi_header_parse().

Torsten


Attachment: pgp9eg4cXfAVB.pgp
Description: PGP signature

Reply via email to