You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Anthony Brock <ab...@georgefox.edu> on 2001/06/26 00:50:37 UTC

mod_perl 1.25, CGI.pm and POST

We recently upgraded our Apache server from 1.3.12 with mod_perl 1.24 and 
php 3 to 1.3.20 with mod_perl 1.25 and php4.0.5.  This included an 
unexpected upgrade from Perl 5.005_03 to Perl 5.6.0 since the new version 
of Apache was compiled using Sun Workshop 5.0. However, since the upgrade, 
I have noticed that several scripts (actually, every CGI.pm script) we used 
to POST to now acts as if it is NOT being posted to.  The following code 
fails to return anything into @parameters despite working yesterday (before 
the upgrade):

my $q = new CGI;
my @parameters = $q->param();

However, if I change the submission type from POST to GET, the script 
starts functioning perfectly.

Does anyone know what would cause this type of behavior? I am at a loss as 
to how to proceed ... I am including below an example script which exhibits 
this behavior consistently on my server.

The server is a Solaris 7 64-bit, Sun Ultra Enterprise 250 (dual processor).

#!/usr/bin/perl -w

# This file is intended to be INCLUDED from an SHTML file,
#   NOT directly executed!

use strict;
use CGI;

my $q = new CGI;
my @parameters = $q->param();

print $q->header;

# Now display the search form
print $q->start_form(-method => 'post') . $q->start_table({align => 'center'});
print "<BR>\n";
print $q->textfield(-name      => 'title',
                     -size      => 32,
                     -maxlength => 255);
print "<BR>\n";
print $q->submit({name => 'POST Search'});
print "<BR>\n\n";
print $q->end_form();

print $q->start_form(-method => 'get') . $q->start_table({align => 'center'});
print "<BR>\n";
print $q->textfield(-name      => 'title',
                     -size      => 32,
                     -maxlength => 255);
print "<BR>\n";
print $q->submit({name => 'GET Search'});
print "<BR>\n\n";
print $q->end_form();

if (@parameters)
{
   foreach my $elem (@parameters)
   {
     print "$elem = " . $q->param($elem) . "<br>\n";
   }
}

print $q->end_html();





******************************************************************************
* Anthony Brock                                         abrock@georgefox.edu *
* Director of Network Services                         George Fox University *
******************************************************************************


Re: mod_perl 1.25, CGI.pm and POST

Posted by Joachim Zobel <nc...@netcologne.de>.
At 15:50 25.06.2001 -0700, you wrote:

[...]

>However, if I change the submission type from POST to GET, the script 
>starts functioning perfectly.
>
>Does anyone know what would cause this type of behavior? I am at a loss as 
>to how to proceed ... I am including below an example script which 
>exhibits this behavior consistently on my server.

There has been a change in 1.25 concerning reading of STDIN (this is what 
POST does). Dough MacEachern mentioned this some days ago.

IIRC $r->read() now returns nothing instaed of hanging if STDIN has already 
been read. I would conjecture that somehow your CGI.pm reads STDIN twice, 
overwriting the first read with said nothing.

[...]

># This file is intended to be INCLUDED from an SHTML file,
>#   NOT directly executed!

Did this ever work with POST? You can not POST to an SSI.

Joachim

--
"... ein Geschlecht erfinderischer Zwerge, die fuer alles gemietet werden
koennen."                            - Bertolt Brecht - Leben des Galilei