[cgiapp] Discrepancy between CGI and CGI::Simple

Ron Savage ron at savage.net.au
Mon Feb 27 16:21:28 EST 2012


Hi Mark

On 28/02/12 01:29, Mark Stosberg wrote:
> On 02/19/2012 04:39 PM, Ron Savage wrote:
>> Hi Folks
>>
>> Firstly, the code:
>> <===8><===>
>> #!/usr/bin/env perl
>>
>> use feature 'say';
>>
>> use CGI;
>> use CGI::Simple;
>>
>> # --------------
>>
>> say 'CGI: ', CGI ->  new ->  redirect;
>> say 'CGI::Simple: ', CGI::Simple ->  new ->  redirect;
>> <===8><===>
>>
>> Then the output:
>> <===8><===>
>> CGI: Status: 302 Found
>> Location: http://localhost
>>
>>
>> CGI::Simple: Status: 302 Moved
>> Location: http://localhost/home/ron/bin/x.pl
>>
>> <===8><===>
>>
>> It's the 302 line I'm interested in. Is this discrepancy by design or not?
>
> As someone who has done some review and maintenance of both modules,
> it's hard to say.
>
> CGI::Simple forked a long time ago and they haven't stayed in sync. I've
> found that both has some fixes that the other has lacked. (Although I've
> done work to minimize them).
>
> In this case, I would compare each against it's own docs. If the docs
> differ about the expected behavior, then I would say it's by design. If
> the docs don't differ, one of them have a bug.
>
> <looks>
>
> In this case, it looks like the behavior of redirect() with no arguments
> is "undefined" in both cases.
>
> It's tempting to suggest that they should both be throwing an error in
> this case, as it's not clear what a "default" redirect() should be.

Good points.

However, if I make the url explicit:

#!/usr/bin/env perl

use feature 'say';

use CGI;
use CGI::Simple;

# --------------

say 'CGI: ', CGI -> new -> redirect('http://127.0.0.1/');
say 'CGI::Simple: ', CGI::Simple -> new -> redirect('http://127.0.0.1/');

I still get:

CGI: Status: 302 Found
Location: http://127.0.0.1/

CGI::Simple: Status: 302 Moved
Location: http://127.0.0.1/


So, I'll log a bug(like) report for CGI::Simple and see what Andy says.

OK. Done that.

Looking at https://metacpan.org/module/Apache2::Controller::Refcard I'd 
have to say both Moved and Found are arguable, which is a pity.

-- 
Ron Savage
http://savage.net.au/
Ph: 0421 920 622


More information about the cgiapp mailing list