Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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


In reply to SpeedyCGI and POSTs using CGI::Simple by zigdon

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-24 02:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found