File upload error
Hello, All, This might be a bit offtopic, but while uploading a file to a server, all zeros (0x0) are replaced with spaces (0x20). What is wrong with the following code then or what's wrong with the server configuration? I am using HTML::Mason with Apache server 1.3.22 under RedHat Linux 6.2 When I am doing the same on the Win32 (local devel machine, no problem occurs). # UPLOADING IMAGE if ( my $upload = $r-upload ) { $url = $upload-filename; $url =~ s/((?:[^\/\\]*?[\/\\]*?)*)([\w\s\.\[\]]*$)/$2/; my $fh = $upload-fh; my $buffer = ; my $fullpath = $ENV{DOCUMENT_ROOT}; # w/o trailing slash $fullpath =~ s/docs.*/images\//; # adding missing slash my $bytesread = 0; if ( sysopen OUTPUT, $fullpath . $url, O_CREAT | O_WRONLY | O_EXCL ) { binmode $fh; binmode OUTPUT; while ( my $bytes = sysread( $fh, $buffer, 65536 ) ) { syswrite( OUTPUT, $buffer ); $bytesread += $bytes; } close OUTPUT; } else { $m-out( BRCouldn't open . $fullpath . $url ); } } # END UPLOADING Alexei mailto:[EMAIL PROTECTED]
Re: File upload error
On Fri, 21 Dec 2001, Alexei Danchenkov wrote: This might be a bit offtopic, but while uploading a file to a server, all zeros (0x0) are replaced with spaces (0x20). What is wrong with the following code then or what's wrong with the server configuration? I am using HTML::Mason with Apache server 1.3.22 under RedHat Linux 6.2 When I am doing the same on the Win32 (local devel machine, no problem occurs). I think you are using Russian Apache. http://apache.lexa.ru/configure.html#charsetrecodemultipartforms Igor Sysoev
Apache KeepAlive
Has anyone encountered issues when setting 'KeepAlive On' in there apache conf? After an initial request it seems that none of my handlers are called and the apache handlers take control. After a period of time the appropriate handlers seem to operate. If I reload quickly the same issue occurs. -Thanks
Apache KeepAlive
It seems to stop occurring if I set MaxRequestPerChild to One as well. Thanks,
Re: PerlWarn and syslog
On Thu, Dec 20, 2001 at 01:59:18PM -0500, Geoffrey Young wrote: If you just print to STDERR you might want to look at Apage::LogSTDERR on CPAN. I took at look on CPAN and was unable to find this module or any reference to it. Any idea if it has been merged into some other module or if it has just gone away? over the years, the folks at critical path keep teasing with talk of releasing Apache::LogSTDERR, but I don't think anyone outside of CP (Doug, Brian, Paul) has actually seen it :) My apologies. I never realized that it had never been released. I'm volunteering to maintain it, so I'll publish it under my CPAN id soon.. For now you can visit: http://www.modperlcookbook.org/code.html and pick up a copy. Thanks for the info. I've taken the various suggestions and am going with Errorlog | /some/perl/script.pl. Thanks to all who responded. I really appreciate the help. -Lance
Class::Singleton dies on warn?
Hi, I just started experimenting with Class::Singleton to store some static config information. I subclassed it, put a couple test variables in it, and loaded in my HTML::Mason page. Everything seemed fine. Then I added a simple warn statement to the _instance_new() method so I could verify exactly when it got instantiated from scratch, and it basically got treated like a die statement, spewing the standard Mason stack trace that Mason normally does on run-time errors. Is this a bug or a feature? The solution seems to be to avoid warning statements like the plague in any Singleton objects. Versions: Apache: 1.3.20 mod_perl 1.26 perl 5.6.1 HTML::Mason1.03 Class::Singleton1.03 OS: Linux, kernel 2.2.19 Thanks, Wes Sheldahl
Re: What phase am I in?
DR == Dave Rolsky [EMAIL PROTECTED] writes: It's called current_callback(). DR Grr, its not documented when I do 'perldoc Apache'. There's a lot of stuff not so documented. The mod_perl book has much more complete docs. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D.Khera Communications, Inc. Internet: [EMAIL PROTECTED] Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/
RE: File handle, STDOUT, help
Although no one responded, I figured it out, my $io = select(); will give me a handle to the default output file handle, which is all I needed... everything works fine... Just in case anyone cared -Tripp -Original Message- From: Tripp Donnelly Sent: Thursday, December 20, 2001 12:12 PM To: [EMAIL PROTECTED] Subject: File handle, STDOUT, help Please forgive me if this is in the documentation somewhere. I have been unable to find it. Also, please note, although I am not a novice at Perl, the more interesting uses of file handles, STDOUT, redirection and such are over my head. I'm having a problem with a mod_perl app I'm working on. The goal is to have a mod_perl app that zips up a bunch of files, and sends it to you, without creating any temporary files (The zips could get huge). I have it working, but the way I'm doing it, the number of bytes downloaded is not logged (well, it shows 5 bytes downloaded for a multi megabyte zip). I understand this, because I'm writing directly to the socket. What I don't understand is how to work around the problem... Here's the important segment of my code (Much cut out): sub handler { my $r = shift; my $c = $r-connection; my $fd = $c-fileno(); my $io = new IO::Handle; $io-fdopen ( $fd, w ); $io-autoflush(1); $zip-writeToFileHandle($io, 0); $io-close; I'm using Archive::Zip to zip the files up. It requires a file handle to write out to (or an actual file, but I don't want any temp files, I want to create zips on the file, and send them directly to the end user). The end goal: send the zip file, without using temp files, and log the size downloaded through normal apache logging (I have custom logging handler to log the info to a database, but the normal access log is showing only 5 bytes downloaded too). Thanks, - Tripp Donnelly - Systems Integrator - BG Telecommunications - www.BGTelecommunications.com - [EMAIL PROTECTED] - (314) 439-0100 ext 28
Re: What phase am I in?
On 21 Dec 2001, Vivek Khera wrote: DR == Dave Rolsky [EMAIL PROTECTED] writes: It's called current_callback(). DR Grr, its not documented when I do 'perldoc Apache'. There's a lot of stuff not so documented. The mod_perl book has much more complete docs. Which is nice for ORA and the books authors, but fairly irritating for folks like myself. Hell, I have the book but I don't always have it with me. I'd submit patches for this but I'm figuring 1.2x will be out of date soon enough with 2.0 in the works. Hopefully that will be better documented and if not, I can always help out. -dave
Re: What phase am I in?
I have the book but I don't always have it with me. That chapter is actually available for free on-line at http://www.modperl.com/. - Perrin
cvs commit: modperl-2.0/t/filter/TestFilter buckets.pm input_body.pm input_msg.pm
stas01/12/21 03:30:39 Modified:t/apisend_fd.t sendfile.t t/filter/TestFilter buckets.pm input_body.pm input_msg.pm Log: - remove the redundant loading of Test and Apache::Test in certain tests Revision ChangesPath 1.4 +1 -2 modperl-2.0/t/api/send_fd.t Index: send_fd.t === RCS file: /home/cvs/modperl-2.0/t/api/send_fd.t,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- send_fd.t 2001/12/20 03:54:41 1.3 +++ send_fd.t 2001/12/21 11:30:38 1.4 @@ -1,8 +1,7 @@ use strict; use warnings FATAL = 'all'; -use Test; -use Apache::Test (); +use Apache::Test; use Apache::TestRequest; plan tests = 3; 1.4 +1 -2 modperl-2.0/t/api/sendfile.t Index: sendfile.t === RCS file: /home/cvs/modperl-2.0/t/api/sendfile.t,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- sendfile.t2001/12/20 03:54:41 1.3 +++ sendfile.t2001/12/21 11:30:38 1.4 @@ -1,8 +1,7 @@ use strict; use warnings FATAL = 'all'; -use Test; -use Apache::Test (); +use Apache::Test; use Apache::TestRequest; plan tests = 3; 1.4 +0 -1 modperl-2.0/t/filter/TestFilter/buckets.pm Index: buckets.pm === RCS file: /home/cvs/modperl-2.0/t/filter/TestFilter/buckets.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- buckets.pm2001/04/20 00:38:09 1.3 +++ buckets.pm2001/12/21 11:30:38 1.4 @@ -4,7 +4,6 @@ use warnings FATAL = 'all'; use Test; -use Apache::Test (); use Apache::Filter (); use APR::Brigade (); use APR::Bucket (); 1.8 +0 -2 modperl-2.0/t/filter/TestFilter/input_body.pm Index: input_body.pm === RCS file: /home/cvs/modperl-2.0/t/filter/TestFilter/input_body.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- input_body.pm 2001/11/06 00:07:53 1.7 +++ input_body.pm 2001/12/21 11:30:38 1.8 @@ -5,8 +5,6 @@ use base qw(Apache::Filter); #so we inherit MODIFY_CODE_ATTRIBUTES -use Test; -use Apache::Test (); use Apache::Const -compile = qw(M_POST); use APR::Const -compile = ':common'; use APR::Brigade (); 1.8 +0 -2 modperl-2.0/t/filter/TestFilter/input_msg.pm Index: input_msg.pm === RCS file: /home/cvs/modperl-2.0/t/filter/TestFilter/input_msg.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- input_msg.pm 2001/11/06 00:08:46 1.7 +++ input_msg.pm 2001/12/21 11:30:38 1.8 @@ -5,8 +5,6 @@ use base qw(Apache::Filter); -use Test; -use Apache::Test (); use APR::Brigade (); use APR::Bucket ();
cvs commit: modperl-2.0/pod modperl_2.0.pod modperl_design.pod
stas01/12/21 07:03:41 Modified:pod modperl_2.0.pod modperl_design.pod Log: - PerlHandler doesn't exist in 2.0 (without compat enabled) - narrow the pre lines block Revision ChangesPath 1.5 +1 -1 modperl-2.0/pod/modperl_2.0.pod Index: modperl_2.0.pod === RCS file: /home/cvs/modperl-2.0/pod/modperl_2.0.pod,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- modperl_2.0.pod 2001/04/06 02:20:26 1.4 +++ modperl_2.0.pod 2001/12/21 15:03:41 1.5 @@ -681,7 +681,7 @@ PerlInterpMaxRequests 1 PerlInterpStart 1 PerlInterpMax 1 -PerlHandler Apache::Registry +PerlResponseHandler Apache::Registry /Location Will use a fresh interpreter with its own namespace to handle each 1.4 +5 -4 modperl-2.0/pod/modperl_design.pod Index: modperl_design.pod === RCS file: /home/cvs/modperl-2.0/pod/modperl_design.pod,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- modperl_design.pod2001/06/29 07:46:02 1.3 +++ modperl_design.pod2001/12/21 15:03:41 1.4 @@ -161,10 +161,11 @@ Perl*Handlers are now compiled, that is, the various forms of: - PerlHandler MyModule (defaults to MyModule::handler or MyModule-handler) - PerlHandler MyModule-handler - PerlHandler $MyObject-handler - PerlHandler 'sub { print foo\n }' + PerlResponseHandler MyModule-handler + # defaults to MyModule::handler or MyModule-handler + PerlResponseHandler MyModule + PerlResponseHandler $MyObject-handler + PerlResponseHandler 'sub { print foo\n }' are only parsed once, unlike 1.xx which parsed every time the handler was used. there will also be an option to parse the handlers at