in reply to Re: Apache::exit question
in thread Apache::exit question

Thanks and yes, we're using mod_perl 1. In my situation, it's not merely a redirect. The code is supposed to redirect back to the login page after some very defined login problems...so I also need to be able to abort the login prior to the redirect. (If I use a return, the login isn't aborted.) Right now, the code handles the flow exactly the way we want, except for the error in the log, which we don't want to see.

Replies are listed 'Best First'.
Re^3: Apache::exit question
by perrin (Chancellor) on Jul 21, 2008 at 16:30 UTC
    Can you explain "If I use a return, the login isn't aborted" a bit more? What are you trying to avoid? A custom log handler that does something if the person is logged in? I think there must be a more elegant solution than calling Apache::exit().

      There are several conditions under which user's credentials might be valid, but the login would need to be refused anyway. The subroutine with the Apache::exit is used to handle these cases. Prior to exiting, the subroutine sets up a redirect back to the login page (with an error displayed to the user) that ends up as the resulting page after the exit. If a return is used instead of an exit, the login proceeds anyway, which we don't want.

      Obviously, the exit is handling some things that need to be unset to prevent the login, but I don't wish to use this forum to figure out how to deal with those things since the Apache::exit already achieves them. If, however, there is a way to call Apache::exit (or something else that would likely have the same effect on the login request) as described previously, but without logging the error in the logs, that would be the easiest fix. If there isn't, then I'll go some other route. Thanks....

        It sounds like you're saying that you call exit() just as a short-circuit to avoid running some of your own code that would otherwise run. It doesn't skip any apache phases, so I assume that's all it's doing for you. You could get a similar effect by using exceptions and an eval block.

        IIRC, Apache::exit is not supposed to log an error, but that may have changed at some point. If you want the details, the best place to ask is the mod_perl list.