tbjers has asked for the wisdom of the Perl Monks concerning the following question:

I have searched in all the places I could think of for a solution to this problem, so I apologize if it has been asked before.

My application uses CGI::Application::Dispatch for routing, it's all set up through mod_perl 1.x running in Apache 1.3.x.

My CGI::Application uses CGI::Application::Plugin::Apache for integration with mod_perl and easier handling of cookies and redirects.

When I try to set a status (from within a runmode) other than 400, 404, or 500, I simply get a blank screen with no output. The 400, 404, and 500 responses produce the correct results.

Sample httpd.conf entry:

<Location /app> SetHandler perl-script PerlHandler Sample::Dispatch </Location>

Sample CGI::Application::Dispatch:

package Sample::Dispatch; use strict; use warnings; use CGI::Application::Dispatch; use base qw(CGI::Application::Dispatch); sub dispatch_args { return { prefix => 'Sample', table => [ q{} => { app => 'Application', rm => 'index' }, ], }; } 1;

Sample CGI::Application:

package Sample::Application; use strict; use warnings; use base qw(CGI::Application); use CGI::Application::Plugin::Apache qw(:all); sub setup { my ( $self, $args ) = @_; $self->run_modes('index' => 'index'); $self->start_mode('index'); return 1; } sub index { my ( $self, $args ) = @_; $self->header_type('none'); $self->query->status(403); return q{}; } 1;
If you set the value of $self->query->status() to 400, 404, and 500 it works as expected. Why does it not support setting any other type of status?

Replies are listed 'Best First'.
Re: Return 403 from within CGI::Application runmode
by scorpio17 (Canon) on Feb 11, 2010 at 22:32 UTC

    Try changing your index runmode to:

    sub index { my $self = shift; $self->header_props( -status => '403 Forbidden'); return ''; }

      With this I get the exact same behavior as I did when using CGI::Application::Plugin::Apache and Apache::Request->status(). Only 400, 404, and 500 work.

      Could this be a limitation inside CGI::Application::Dispatch?

        Possibly.

        I've done something similar, which works for me... but I'm not using mod_perl, nor CGI::Application::Dispatch, nor CGI::Application::Plugin::Apache. So, maybe something in one of those is behaving badly?

Re: Return 403 from within CGI::Application runmode
by Anonymous Monk on Feb 11, 2010 at 19:44 UTC
    Prove it ;)
      What do you want me to prove? That I searched everywhere, or that CGI::Application does not handle anything but 400, 404, and 500 statuses?

        For proof, you could show a reduced version of your program that requires nothing outside of CGI::Application that exhibits the behaviour you claim.

        What Corion said, and it should be easy (copy/paste) since you've already done it :)