You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Joshua N Pritikin <jp...@pobox.com> on 2005/03/16 04:17:47 UTC

CGI::Simple 0.077

CGI::Simple doesn't work with mod_perl 1.999.20:

 $data = $self->{'.mod_perl'} ? Apache->request->args :
          $ENV{'QUERY_STRING'} || $ENV{'REDIRECT_QUERY_STRING'} || '';

Apache->request->args returns an Apache::RequestRec instead of a native
perl data structure.

What is the new magic to get this to work?


Re: CGI::Simple 0.077

Posted by Joshua N Pritikin <jp...@pobox.com>.
On Wed, 2005-03-16 at 17:51 +0530, Joshua N Pritikin wrote:
> Now I'm getting a different error:
> 
>    '.cgi_error' => '500 Bad read on multipart/form-data! wanted 880, got
> 0',

Ah, I see.

Careful examination of CGI.pm suggests that STDIN no longer works for
POST data.

I changed all the sysreads from STDIN to use Apache->request->read and
it started working again.

I'll file a patch on cpan.


Re: CGI::Simple 0.077

Posted by Joshua N Pritikin <jp...@pobox.com>.
On Wed, 2005-03-16 at 11:24 +0530, Joshua N Pritikin wrote:
> I'm trying to get parameters from multipart/form-data.

D'oh!  I was passing the request object into CGI::Simple.

  CGI::Simple->new($r);

I guess I should pass in nothing, e.g.:

  CGI::Simple->new();

Now I'm getting a different error:

   '.cgi_error' => '500 Bad read on multipart/form-data! wanted 880, got
0',

Any clue what is going on?


Re: CGI::Simple 0.077

Posted by Joshua N Pritikin <jp...@pobox.com>.
On Tue, 2005-03-15 at 23:21 -0500, Perrin Harkins wrote: 
> On Wed, 2005-03-16 at 08:47 +0530, Joshua N Pritikin wrote:
> > CGI::Simple doesn't work with mod_perl 1.999.20:
> > 
> >  $data = $self->{'.mod_perl'} ? Apache->request->args :
> >           $ENV{'QUERY_STRING'} || $ENV{'REDIRECT_QUERY_STRING'} || '';
> > 
> > Apache->request->args returns an Apache::RequestRec instead of a native
> > perl data structure.
> 
> Really?  It should still give you the query string.
> 
> http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_args_

Oh!  And it does.  The problem is elsewhere.

I'm trying to get parameters from multipart/form-data.  Here is what the
CGI::Simple object looks like:

$VAR1 = bless( { 
                 '.parameters' => [
                                    'Apache::RequestRec'
                                  ],
                 '.crlf' => '
',
                 '.mod_perl' => 2,
                 '.globals' => {
                                 'DEBUG' => 0,
                                 'NO_UNDEF_PARAMS' => 0,
                                 'NO_NULL' => 1,
                                 'FATAL' => -1,
                                 'USE_PARAM_SEMICOLONS' => 1,
                                 'DISABLE_UPLOADS' => 1,
                                 'USE_CGI_PM_DEFAULTS' => 0,
                                 'NPH' => 0,
                                 'POST_MAX' => 8192,
                                 'HEADERS_ONCE' => 0
                               },
                 'Apache::RequestRec' => [
                                           'SCALAR(0x877fedc)'
                                         ],
                 '.fieldnames' => {
                                    'Apache::RequestRec' => 1
                                  },
                 '.cookies' => {
                                 'OHL_ID' => bless( {
                                                      'value' => [
                                                                   '25'
                                                                 ],
                                                      'name' => 'OHL_ID',
                                                      'path' => '/'
                                                    }, 'CGI::Simple::Cookie' )
                               },
                 '.header_printed' => 1
               }, 'CGI::Simple' );

Somehow the Apache::RequestRec is not being unpacked.  There isn't any special
casing for mod_perl in this code path so maybe a special case needs to be added?


Re: CGI::Simple 0.077

Posted by Perrin Harkins <pe...@elem.com>.
On Wed, 2005-03-16 at 08:47 +0530, Joshua N Pritikin wrote:
> CGI::Simple doesn't work with mod_perl 1.999.20:
> 
>  $data = $self->{'.mod_perl'} ? Apache->request->args :
>           $ENV{'QUERY_STRING'} || $ENV{'REDIRECT_QUERY_STRING'} || '';
> 
> Apache->request->args returns an Apache::RequestRec instead of a native
> perl data structure.

Really?  It should still give you the query string.

http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_args_

and possibly related...

http://perl.apache.org/docs/2.0/user/porting/compat.html#C__r_E_gt_args__in_an_Array_Context

- Perrin