Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Perl / April 2008



Tip: Looking for answers? Try searching our database.

Leopard, Apache and CGI Uploads

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bryandaimler@netscape.net - 24 Apr 2008 21:59 GMT
I have a Perl file upload script I'd been using for years under Apache 1 in Tiger. I haven't
modified it in ages. No mod_perl, just CGI.pm and the default Perl installation. It's always worked
fine for files of any size (some as many as a gigabyte and taking more than an hour to upload), but
since upgrading to Leopard, with its Apache2 nonsense, the script fails on large files -- anything
over a megabyte -- with this being output to the browser:

"CGI.pm: Server closed socket during multipart read (client aborted?).".

This is the only error message logged, too. I've tested this with multiple clients on different
operating systems and it's the same every time, unless the file's smaller than 1MB, in which case
the script executes as it should. I added a debugging line to the upload hook that runs when I first
create my CGI query object, and it reports the bytes increasing up to a point, after which it keeps
logging these messages but the number of bytes stays static. It's never the exact same number but
the files always seem to fail above 1 megabyte, with about 1.4 being the upper limit I've seen so far.

Any ideas? Thanks
jeremiah@jeremiahfoster.com - 25 Apr 2008 13:48 GMT
Hello Bryan,

> I have a Perl file upload script I'd been using for years under  
> Apache 1 in Tiger. I haven't modified it in ages. No mod_perl, just  
> CGI.pm and the default Perl installation. It's always worked fine  
> for files of any size (some as many as a gigabyte and taking more  
> than an hour to upload), but since upgrading to Leopard, with its  
> Apache2 nonsense,

Um, apache2 rocks. It has a much better configuration layout,  
particularly for virtual hosts, and is a more secure web server. Once  
you get used to it you'll agree.

> the script fails on large files -- anything over a megabyte -- with  
> this being output to the browser:
[quoted text clipped - 13 lines]
>
> Any ideas? Thanks

Well I know that CGI.pm has tools to limit the size of uploads, or  
more specifically tools for controlling uploaded files as they get  
spooled to disk, but it appears that you did not change those settings  
so I am not sure if that is your problem or not. Here are some things  
you can add to your perl script to get more information:

Use Carp, diagnostics, and warnings, if you haven't already:

use warnings
use diagnostics
use CGI::Carp 'fatalsToBrowser'

That last use directive, (the one for CGI::Carp), will print warnings  
to your browser which may help if you chose to diagnose the problem  
with a browser. You'd probably want to turn that off once the problem  
is solved, it reveals juicy information about the cgi environment.

You can change the type and amount of messages your error log receives  
in the httpd.conf file for your specific domain - I think the default  
is "warn", but you can set higher levels which might give you some  
more info, look for this stanza:

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error,  
crit,
        # alert, emerg.
        LogLevel warn

Set it to info or debug for more info on errors. apache2 does not use  
httpd.conf anymore, at least on other operating systems, but Apple has  
decided in their infinite wisdom to fork apache2 and they bundle  
configuration in httpd.conf. Bad Apple. So you will have to look in /
etc/apachce2/httpd.conf to find if there are any settings there that  
are limiting your uploads, though a cursory check of my httpd.conf  
file under Leopard shows nothing that might point to limits on  
uploads, but as I mentioned, Apple takes liberties with apache so you  
never know. :)

Hope that helps,
       
    Jeremiah
bryandaimler@netscape.net - 25 Apr 2008 16:45 GMT
> Um, apache2 rocks. It has a much better configuration layout,
> particularly for virtual hosts, and is a more secure web server. Once  
> you get used to it you'll agree.

Well, I just use it for a couple old scripts and some static html pages for personal use, so
whatever advantage it may have is lost on me. The least they could have done is keep apache1 as an
option, or convert my httpd.conf as part of the Leopard upgrade like they do for the data or
configuration files of other upgraded programs. It is strange that if, as you say, a 'normal'
Apache2 installation doesn't use httpd.conf, Apple decided to use it anyway for some reason, yet not
to carry over any info from Tiger. I wonder why they even bothered to fork it.

> Well I know that CGI.pm has tools to limit the size of uploads, or more
> specifically tools for controlling uploaded files as they get spooled to
> disk, but it appears that you did not change those settings so I am not
> sure if that is your problem or not. Here are some things you can add to
> your perl script to get more information:

I didn't see anything in the documentation about controlling uploaded files as they're spooled,
other than the '-private_tempfiles' security pragma which I doubt would apply here. $POST_MAX and
$DISABLE_UPLOADS are set to their defaults of no max and uploads enabled. The Leopard upgrade itself
probably included a newer version of CGI.pm than I had before, and after discovering this problem I
upgraded to 3.37 from Leopard's 3.15 just to see if that would help, but the results and log
messages are identical in either case.

> Use Carp, diagnostics, and warnings, if you haven't already:
>
[quoted text clipped - 10 lines]
>
> Set it to info or debug for more info on errors.

My script already had those 3 modules turned on -- forgot to comment them out lo those many years
ago since I haven't had an error in ages. I did change the Apache logging to 'debug' as you
suggested but all it added were a few messages about scoreboard files, module loading and the
routine launching of child processes.

Thanks,
Bryan
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.