Re: PerlAuthenHandler returns HTTP_UNAUTHORIZED (401) but Apache sends REDIRECT (302) and drops Set-Cookie and WWW-Authenticate header

Matisse Enzer <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
Ahh, very interesting.

I actually did want to use a full url with scheme and host.

What we wanted was a response of type HTTP_UNAUTHORIZED with a Location header as well as the other headers I added.

But, perhaps that's not a reasonable thing to want, and we can provide a URI to a page on the same server.

-M

On May 28, 2011, at 2:31 PM, Torsten Förtsch wrote:

> On Saturday, May 28, 2011 21:10:14 Matisse Enzer wrote:
>>    $r->custom_response( HTTP_UNAUTHORIZED, $uri );
>>    return HTTP_UNAUTHORIZED
> 
> Make sure $uri does not contain the hostport part. It must start with a
> slash. The next lines are from modules/http/http_request.c:
> 
>    /*
>     * Two types of custom redirects --- plain text, and URLs. Plain text has
>     * a leading '"', so the URL code, here, is triggered on its absence
>     */
> 
>    if (custom_response && custom_response[0] != '"') {
> 
>        if (ap_is_url(custom_response)) {
>            /*
>             * The URL isn't local, so lets drop through the rest of this
>             * apache code, and continue with the usual REDIRECT handler.
>             * But note that the client will ultimately see the wrong
>             * status...
>             */
>            r->status = HTTP_MOVED_TEMPORARILY;
>            apr_table_setn(r->headers_out, "Location", custom_response);
>        }
>        else if (custom_response[0] == '/') {
> [...]
>            r->method_number = M_GET;
>            ap_internal_redirect(custom_response, r);
>            return;
> 
> I think you want to enter the "else if" branch.
> 
> Further, make sure the document that is redirected to ends in a
> Apache2::Const::OK.
> 
> Torsten Förtsch
> 
> -- 
> Need professional modperl support? Hire me! (http://foertsch.name)
> 
> Like fantasy? http://kabatinte.net
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.