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

UPDATE: I've tracked this down through further testing to a conflict between certain builds of apache and certain versions of CGI.pm. This is discussed on various websites under the error message of
CGI.pm: Server closed socket during multipart read
Sadly my webhost is technically challenged enough that they don't know how to fix this. Switching to another host where script works. Thanks to all your help.

ORIGINAL MESSAGE
------------------
Hello Monks, I've just discovered you all and hoping someone might have knowledge of my problem. I have some code that runs fine on one hosting company but fails on another: iPowerWeb. I've created a super simple test listed below.

#!/usr/bin/perl use Image::Magick; use CGI; my $req = new CGI; print "Content-type: text/html\n\n"; print "<h1>Test Result</h1>"; print "Everything OK";


SCENARIO: a simple html form with a single file upload control calls the script above. The script does nothing except ask to use two modules and then ask for a new CGI object.

RESULT: The code works fine with files of less than 15k. It fails with files over 20k. Failure is a 500 server error. Running the script with strict and -w produce no errors or warnings other than the usual "premature end of script headers".

ALTERNATE TEST 1 -- CGI WORKING OK WITHOUT IMAGE MAGICK: Thanks to tips from Monks "Marto" and "Zentara" i tried the exact script as above except i removed the "use Image::Magick" line and added a simple line to test if CGI object was created. Result is that all files upload properly and a cgi object is created properly. So it is the interaction with Image::Magick and CGI that is the problem.

#!/usr/bin/perl use CGI; my $req = new CGI; my $f = $req->param("TOPPIX"); print "Content-type: text/html\n\n"; print "<h1>Test Result</h1>"; print "Everything OK $f";


ALTERNATE TEST 2 -- WORKS IF CGI OBJECT NOT CREATED: Another test with removal of the "my $req = new CGI;" line allows the script to function properly with all file sizes.

#!/usr/bin/perl use Image::Magick; use CGI; print "Content-type: text/html\n\n"; print "<h1>Test Result</h1>"; print "Everything OK";


QUESTION: Anyone know why this could be happening? iPowerWeb folks are stumped and have bailed on it. My apologies if this is outside the realm of the monestary's usual consideration. Happy to have found you either way. Many thanks, barry

Replies are listed 'Best First'.
Re: large file upload fails on 'new CGI' request
by marto (Cardinal) on Jun 12, 2005 at 00:50 UTC
    Hi,

    If you dont find anything in the server logs, just for giggles, try replacing:

    use CGI;

    With

    use CGI::Carp qw(fatalsToBrowser);

    And see if anything is returned to the browser.
    Hope this helps,

    Cheers,

    Martin
      Thanks for the tip Martin. I tried it and got carped at that "Can't locate object method 'new' via package "CGI". Huh? From that i decided to create another test that just used CGI and not Image::Magick. (see reworded question)

      RESULT OF "use CGI": Everything worked great for all file uploads. The cgi object was created and held the correct form info.

      RESULT OF "use CGI::Carp": CGI::Carp always gives the error above...that it can't located the 'new' package. I guess that means that my webhost has more problems with their perl modules that just image::magick...if cgi::carp always fails but cgi alone doesn't!?

      thanks,
      stonebreaker
      One last note on this Martin. Using CGI::Carp and more test scripts i got an error finally that led to understanding of the problem. see UPDATE to my question above. Thanks again for your advice.
Re: large file upload fails on 'new CGI' request
by zentara (Cardinal) on Jun 12, 2005 at 12:23 UTC
    Maybe your version of the CGI module has the CGI::POST_MAX value hardwired to be low, just big enough to get normal form posts. Try setting it higher in your script and see if it works.
    $CGI::POST_MAX= 100000;
    If that works, then you've found your problem. If not, it's probably some problem with the server configuration.

    I'm not really a human, but I play one on earth. flash japh
      Thanks for the POST_MAX idea. I tried it and it did not change the result. but it did help me plan another test which i describe in my reworded question. Basically the script without the "use Image::Magick" works fine...meaning that CGI is fine on it's own. just an interaction with "Image::Magick" that brings it down.
Re: large file upload fails on 'new CGI' request
by redhotpenguin (Deacon) on Jun 12, 2005 at 00:14 UTC
    Getting information on the web server and what versions of Perl and CGI are running on both hosting setups may lead to some insight. If you script works on one setup but not the other, chances are the issue is due to the way the hosting environment is setup. 20k is a small upload.
Re: large file upload fails on 'new CGI' request
by PodMaster (Abbot) on Jun 11, 2005 at 22:11 UTC
    RESULT: The code works fine with files of less than 15k. It fails with files over 20k. Failure is a 500 server error. Running the script with strict and -w produce no errors or warnings.
    That is highly unlikely. The error log should have a better error message.

    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.

      The error log only reports the usual "premature end of script headers".
      After some tips from other Monks i created another test that shows that CGI is installed and works fine without Image::Magick involved. see revised question if interested.

      thanks much, stonebreaker