You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Willem Jan Withagen <wj...@withagen.nl> on 2005/05/13 10:02:38 UTC

Problems get DATA part from POST requests.

Hi,

I've inherited a large set of "old" mod_perl/Embperl websites from a crashed 
server.... Programming (mod_)perl is not yet my strongpoint at this moment, 
and the sites do not work when it needs to upload files. (It is a very old, 
selfmade CMS) I have do large experience in sysadmin and scripts in Perl4. :(

It is running on FreeBSD 5.4, Apache/1.3.33 (Unix) Embperl/1.3.6 mod_perl/1.29

And the snippet of code looks like this:
	# Get some fileproperties!
	$filename=$fdat{ImageName};
	$filename=~ m/.*\\(.*)/is;
	$shortname=$1;
	$contentinfo =$fdat{-ImageName} -> {'Content-Type'};

	$contentinfo =~ m/(.*?)\/(.*)/is;
	$contentsort=$1;
	$contenttype=$2;

	print LOG "[$$]ABCD: Opening $tmppath$tmpname.$$\n" ;
     open FILE, "> $tmppath$tmpname.$$" ||
	print LOG "[$$]ABCD: Cannot open file $tmppath$tmpname.$$ for writing\n"; 
#store file in tmp dir.
	binmode FILE;
	$ok=1;
	$oversize=0;
     while ($ok==1)
		{
		$temp=0;
		$temp = read($fdat{ImageName}, $buffer, 16384);
		$size = $size + $temp;
		print FILE $buffer;
		print LOG "[$$]ABCD: Buffer: |$buffer|\n";
		if ($temp ==0) {$ok=0}   # exit, finished reading all data
		if ($size > $maxfilesize) {$oversized=1;$ok=0;} # toooo big		
		}
     close FILE;
  ---------------

The print LOG are my doing....
When this code gets executed it does open the file, filename and contentinfo 
are correctly extracted. Only the data in read is never there. The buffer is 
always empty. But I can not seem to graps why!?

It could be configuration, although I'm led to believe that read-overloading 
is default present with mod_perl/Embperl. I did get Sessions to work with 
Apache::SessionX.

I've also searched the archives but have only found some discussion from 2001 
on this. And it either went away with upgrading mod_perl, or by completely 
overhauling the code. mod_perl is already very recent. And rewriting the code 
is something I try to prevent, since it'll might start to break even more.

Does anybody have suggestions as to where to look??
--WjW

RE: Problems get DATA part from POST requests.

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

> 
> Gerald Richter wrote:
> > Hi,
> > 
> > Which version of Perl and CGI.pm you are using?
> 
> Hi Gerald,
> 
> Both are relatively recent, since I'm using FreeBSD packages.
> And I've even used cpan to upgrade to the most recent CGI.pm
> 
> Perl 5.8.6
> $CGI::VERSION='3.10';
> 

Embperl 1.3.6 does not work with CGI.pm >= 3.01, because there were some
changes in the upload code in CGI.pm. Since Embperl 1.3.6 is not expected to
be updated, because Embperl 2 is the current version, the only possibility
for you is to downgrade CGI.pm (if you want not upgrade Embperl, which
normaly involves some adaptions in your code)

Gerald



Re: Problems get DATA part from POST requests.

Posted by Willem Jan Withagen <wj...@withagen.nl>.
Gerald Richter wrote:
> Hi,
> 
> Which version of Perl and CGI.pm you are using?

Hi Gerald,

Both are relatively recent, since I'm using FreeBSD packages.
And I've even used cpan to upgrade to the most recent CGI.pm

Perl 5.8.6
$CGI::VERSION='3.10';

But opening up CGI.pm shows me also:
# HARD-CODED LOCATION FOR FILE UPLOAD TEMPORARY FILES.
# UNCOMMENT THIS ONLY IF YOU KNOW WHAT YOU'RE DOING.
# $CGITempFile::TMPDIRECTORY = '/usr/tmp';

And if /usr/tmp is the only location used by CGI, then I already know the 
problem.... 'cause /usr/tmp does not exist.
FreeBSD already got: /tmp, /var/tmp

--WjW

> 
> Gerald
> 
> 
> ---------------------------------------------------------------------------
> Gerald Richter            ecos electronic communication services gmbh
> IT-Securitylösungen * Webapplikationen mit Apache/Perl/mod_perl/Embperl
> 
> Post:       Tulpenstrasse 5          D-55276 Dienheim b. Mainz
> E-Mail:     richter@ecos.de          Voice:   +49 6133 939-122
> WWW:        http://www.ecos.de/      Fax:     +49 6133 939-333
> ---------------------------------------------------------------------------
> ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
> ---------------------------------------------------------------------------
> 
>   
> 
> 
>>-----Original Message-----
>>From: Willem Jan Withagen [mailto:wjw@withagen.nl] 
>>Sent: Friday, May 13, 2005 10:03 AM
>>To: modperl@perl.apache.org
>>Subject: Problems get DATA part from POST requests.
>>
>>Hi,
>>
>>I've inherited a large set of "old" mod_perl/Embperl websites 
>>from a crashed server.... Programming (mod_)perl is not yet 
>>my strongpoint at this moment, and the sites do not work when 
>>it needs to upload files. (It is a very old, selfmade CMS) I 
>>have do large experience in sysadmin and scripts in Perl4. :(
>>
>>It is running on FreeBSD 5.4, Apache/1.3.33 (Unix) 
>>Embperl/1.3.6 mod_perl/1.29
>>
>>And the snippet of code looks like this:
>>	# Get some fileproperties!
>>	$filename=$fdat{ImageName};
>>	$filename=~ m/.*\\(.*)/is;
>>	$shortname=$1;
>>	$contentinfo =$fdat{-ImageName} -> {'Content-Type'};
>>
>>	$contentinfo =~ m/(.*?)\/(.*)/is;
>>	$contentsort=$1;
>>	$contenttype=$2;
>>
>>	print LOG "[$$]ABCD: Opening $tmppath$tmpname.$$\n" ;
>>     open FILE, "> $tmppath$tmpname.$$" ||
>>	print LOG "[$$]ABCD: Cannot open file 
>>$tmppath$tmpname.$$ for writing\n"; #store file in tmp dir.
>>	binmode FILE;
>>	$ok=1;
>>	$oversize=0;
>>     while ($ok==1)
>>		{
>>		$temp=0;
>>		$temp = read($fdat{ImageName}, $buffer, 16384);
>>		$size = $size + $temp;
>>		print FILE $buffer;
>>		print LOG "[$$]ABCD: Buffer: |$buffer|\n";
>>		if ($temp ==0) {$ok=0}   # exit, finished 
>>reading all data
>>		if ($size > $maxfilesize) {$oversized=1;$ok=0;} 
>># toooo big		
>>		}
>>     close FILE;
>>  ---------------
>>
>>The print LOG are my doing....
>>When this code gets executed it does open the file, filename 
>>and contentinfo are correctly extracted. Only the data in 
>>read is never there. The buffer is always empty. But I can 
>>not seem to graps why!?
>>
>>It could be configuration, although I'm led to believe that 
>>read-overloading is default present with mod_perl/Embperl. I 
>>did get Sessions to work with Apache::SessionX.
>>
>>I've also searched the archives but have only found some 
>>discussion from 2001 on this. And it either went away with 
>>upgrading mod_perl, or by completely overhauling the code. 
>>mod_perl is already very recent. And rewriting the code is 
>>something I try to prevent, since it'll might start to break 
>>even more.
>>
>>Does anybody have suggestions as to where to look??
>>--WjW
>>
> 
> 
> 


RE: Problems get DATA part from POST requests.

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

Which version of Perl and CGI.pm you are using?

Gerald


---------------------------------------------------------------------------
Gerald Richter            ecos electronic communication services gmbh
IT-Securitylösungen * Webapplikationen mit Apache/Perl/mod_perl/Embperl

Post:       Tulpenstrasse 5          D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de          Voice:   +49 6133 939-122
WWW:        http://www.ecos.de/      Fax:     +49 6133 939-333
---------------------------------------------------------------------------
ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
---------------------------------------------------------------------------

  

> -----Original Message-----
> From: Willem Jan Withagen [mailto:wjw@withagen.nl] 
> Sent: Friday, May 13, 2005 10:03 AM
> To: modperl@perl.apache.org
> Subject: Problems get DATA part from POST requests.
> 
> Hi,
> 
> I've inherited a large set of "old" mod_perl/Embperl websites 
> from a crashed server.... Programming (mod_)perl is not yet 
> my strongpoint at this moment, and the sites do not work when 
> it needs to upload files. (It is a very old, selfmade CMS) I 
> have do large experience in sysadmin and scripts in Perl4. :(
> 
> It is running on FreeBSD 5.4, Apache/1.3.33 (Unix) 
> Embperl/1.3.6 mod_perl/1.29
> 
> And the snippet of code looks like this:
> 	# Get some fileproperties!
> 	$filename=$fdat{ImageName};
> 	$filename=~ m/.*\\(.*)/is;
> 	$shortname=$1;
> 	$contentinfo =$fdat{-ImageName} -> {'Content-Type'};
> 
> 	$contentinfo =~ m/(.*?)\/(.*)/is;
> 	$contentsort=$1;
> 	$contenttype=$2;
> 
> 	print LOG "[$$]ABCD: Opening $tmppath$tmpname.$$\n" ;
>      open FILE, "> $tmppath$tmpname.$$" ||
> 	print LOG "[$$]ABCD: Cannot open file 
> $tmppath$tmpname.$$ for writing\n"; #store file in tmp dir.
> 	binmode FILE;
> 	$ok=1;
> 	$oversize=0;
>      while ($ok==1)
> 		{
> 		$temp=0;
> 		$temp = read($fdat{ImageName}, $buffer, 16384);
> 		$size = $size + $temp;
> 		print FILE $buffer;
> 		print LOG "[$$]ABCD: Buffer: |$buffer|\n";
> 		if ($temp ==0) {$ok=0}   # exit, finished 
> reading all data
> 		if ($size > $maxfilesize) {$oversized=1;$ok=0;} 
> # toooo big		
> 		}
>      close FILE;
>   ---------------
> 
> The print LOG are my doing....
> When this code gets executed it does open the file, filename 
> and contentinfo are correctly extracted. Only the data in 
> read is never there. The buffer is always empty. But I can 
> not seem to graps why!?
> 
> It could be configuration, although I'm led to believe that 
> read-overloading is default present with mod_perl/Embperl. I 
> did get Sessions to work with Apache::SessionX.
> 
> I've also searched the archives but have only found some 
> discussion from 2001 on this. And it either went away with 
> upgrading mod_perl, or by completely overhauling the code. 
> mod_perl is already very recent. And rewriting the code is 
> something I try to prevent, since it'll might start to break 
> even more.
> 
> Does anybody have suggestions as to where to look??
> --WjW
>