Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

SpeedyCGI and POSTs using CGI::Simple

by zigdon (Deacon)
on Sep 29, 2005 at 20:32 UTC ( #496230=perlquestion: print w/replies, xml ) Need Help??

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

I'm running into a little problem with SpeedyCGI that's stumping me. In general, I really like Speedy - I switched some CGI::Simple scripts that had severe performance issues to it, and was amazed at the improvement. The problem is, all those CGIs were just processing GET requests. I'm now trying to write the first one that will accept POSTs, and I can't get it to work. The code itself is very simple:
#!/usr/bin/speedy -wT use strict; use CGI::Simple; use MyApp::Theme; + + use vars qw/$q/; + + $q = new CGI::Simple; + + warn $q->Dump; + + if ($q->param('theme') =~ m#([\w\-:(){} /]+)#) { my $theme = $1; + + my @themes = map {$_->theme} MyApp::Theme->search_like(theme => $the +me."%"); my %matches; + + foreach (@themes) { my $nextslash = index($_, " / ", length $theme); if ($nextslash == -1) { # not found - it's a leaf $matches{$_} = $_; } elsif (not exists $matches{$_}) { substr($_, $nextslash) = ""; $matches{$_} = "$_ / "; } } + + print $q->header; print "<ul>"; foreach (sort keys %matches) { print "<li>$_</li>"; } unless (exists $matches{$theme}) { print "<li>$theme</li>"; } print "</ul>"; }
It accepts a single parameter (theme), and returns an unordered list of similar themes (used in an AJAX autocomplete setup). When I run it under normal perl, everything works great:
$VAR1 = bless( { '.parameters' => [ 'theme', '_' ], '.globals' => { 'DEBUG' => '0', 'NO_UNDEF_PARAMS' => '0', 'NO_NULL' => 1, 'FATAL' => -1, 'USE_PARAM_SEMICOLONS' => '0', 'DISABLE_UPLOADS' => 1, 'USE_CGI_PM_DEFAULTS' => '0', 'NPH' => '0', 'POST_MAX' => 102400, 'HEADERS_ONCE' => '0' }, '.fieldnames' => { '_' => 1, 'theme' => 1 }, '_' => [ '' ], 'theme' => [ 'Some value' ] }, 'CGI::Simple' ); at /var/www/cgi-bin/ac_theme line 16.
When I switch to speedy, I get this:
$VAR1 = bless( { '.globals' => { 'DEBUG' => '0', 'NO_UNDEF_PARAMS' => '0', 'NO_NULL' => 1, 'FATAL' => -1, 'USE_PARAM_SEMICOLONS' => '0', 'DISABLE_UPLOADS' => 1, 'USE_CGI_PM_DEFAULTS' => '0', 'NPH' => '0', 'POST_MAX' => 102400, 'HEADERS_ONCE' => '0' }, '.cgi_error' => '500 Bad read on POST! wanted 48, go +t 0' }, 'CGI::Simple' ); at /var/www/cgi-bin/ac_theme line 16.
What gives? Update: Just occured to me to switch to the regular CGI, and sure enough, everything works again, even under speedy. I guess CGI::Simple isn't doing something right?

-- zigdon

Replies are listed 'Best First'.
Re: SpeedyCGI and POSTs using CGI::Simple
by PodMaster (Abbot) on Sep 30, 2005 at 00:33 UTC
    What gives? Update: Just occured to me to switch to the regular CGI, and sure enough, everything works again, even under speedy. I guess CGI::Simple isn't doing something right?
    The error is '500 Bad read on POST! wanted 48, got 0 which seems to suggest that speedy is messing up. If you're really interested, you should turn on debugging in both modules (and check $!).

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://496230]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2019-05-23 18:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (146 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!