I'm trying to create a mod_perl handler that will sit on top of an existing CGI script. If a particular set of reqs are met (from x ip, y cookie is not set, and this is an intial request), then goto a different CGI (or html page) that pops up a survey and then passes through to the original CGI script.

My first thought was to write a PerlAccessHandler that can check the IP and other reqs. If the reqs are met, set the custom_response to the pop-up (html or cgi) and return FORBIDDEN.

Here's where the problem is. If the reqs are met and I return FORBIDDEN, rather that the custom_response html being displayed, I'm presented with a browser username/password pop-up. Any ideas on how to get around that? Here's a real boiled down snippet that displays the behaviour I'm talking about:

package Foo::BAR::Access; use Apache::Constants qw( :methods :response ); use strict; sub handler { my $r = shift; my $ip = $r->connection->remote_ip; if( $ip =~ /^10.10.1.*$/ ) { $r->custom_response( FORBIDDEN, "/survey.html" ); return FORBIDDEN; } return OK; }
and here's the conf:
<Location /cgi-bin/foo.cgi> PerlAccessHandler Foo::BAR::Access PerlHandler Apache::PerlRun Options ExecCGI PerlSendHeader On </Location>

(there's a lot of logging in the real code so I'm sure it's not the pass through that is causing me problems - yet).

-derby.


In reply to mod_perl and PerlAccessHandler by derby

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.