[cgiapp] CGI::Application::Server bug with regards to $self->query?

Jaldhar H. Vyas jaldhar at braincells.com
Wed Dec 3 17:31:14 EST 2008


I'm using CGI::Application 4.20 with CGI::Application::Server 0.60 on 
Ubuntu Linux 'Intrepid'.   I think there is a problem with the way C::A::S 
handles the query parameters but I wanted to get a second opinion before 
filing a bug.

Take a look at the small program below.


----CUT HERE----
#!/usr/bin/perl
use warnings;
use strict;
use CGI::Application::Server;

my $server = CGI::Application::Server->new();
my $app = TestBug->new();

$server->entry_points({
     '/one.cgi' => $app,
     '/two.cgi' =. 'TestBug',
});
$server->run;

package TestBug;
use base 'CGI::Application';
use warnings;
use strict;

sub setup {
     my ($self) = @_;
     $self->run_modes([qw/ start /]);
}

sub start {
     my ($self) = @_;
     my $q = $self->query;
     return join "\n",
         $q->start_html('test bug') .
         $q->h1($q->param('text')) .
         $q->end_html
     ;
}

1;
----CUT HERE----

If you run this and then go to http://localhost:8080/one.cgi?text=foo
it should say foo and it does.

If you then go to http://localhost:8080/one.cgi?text=bar
instead of saying bar it will still say foo.  In fact it will keep 
outputting foo for any value of text until you restart the server.  it 
seems the $self->query object does not get reinitalized between runs.

If you go to http://localhost:8080/two.cgi?text=foo etc. the output is 
what it should be.

Actually now that I've looked at it, I think the problem is actually in 
CGI::Application not ::Server.  The query object is initialized in new() 
shouldn't this actually happen in run()?


-- 
Jaldhar H. Vyas <jaldhar at braincells.com>


More information about the cgiapp mailing list