Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: Mason upload limit size

by physi (Friar)
on Feb 13, 2004 at 10:06 UTC ( #328762=note: print w/replies, xml ) Need Help??


in reply to Re: Mason upload limit size
in thread Mason upload limit size

Thanks Fletch for your explanation.
Yes I use mod_perl and so I should might be use the last way you mentioned. But that will mean, I can't limit different upload forms to different upload size. Or I have to put each upload form into an own directory and use different My::ApacheHandler for each of them.
Sounds to be to complicated :-)

Maybe I use CGI for the upload stuff. This will also save me for memory problems, which mod_perl maybe will cause by uploading big files ...

Thanks.

-----------------------------------
--the good, the bad and the physi--
-----------------------------------

Replies are listed 'Best First'.
Re: Re: Re: Mason upload limit size
by Fletch (Bishop) on Feb 13, 2004 at 14:25 UTC

    No, you can vary the limit but you just have to make your My::ApacheHandler a little bit fancier.

    package My::ApacheHandler; use base 'HTML::Mason::ApacheHandler'; sub prepare_request { my $self = shift; my $r = shift; my @args; ## <Location /foo> ## PerlSetVar MAH_POST_MAX 1024 ## </Location> ## <Location /bar> ## PerlSetVar MAH_POST_MAX none ## </Location> my $post_max = $r->dir_config( 'MAH_POST_MAX' ); unless( $post_max =~ /^none/ ) { push @args, POST_MAX => $post_max; } Apache::Request->instance( $r, @args ); return $self->SUPER::prepare_request( $r, @_ ); } 1;
      Just checked this out...

      works perfect!

      Thanks ++

      btw: maybe it's worth to implement this in Mason's src!?

      -----------------------------------
      --the good, the bad and the physi--
      -----------------------------------
      

      How can be this code adopted for Apache2? I'm using Apache2 together with Mason and session (MasonX::Apache2Handler as response handler and MasonX::Request::WithApache2Session as request class) and need to limit uploads too.

      Trying to use described solution I get in most cases 500 response (Internal server error). It seems $m to be undefined :-(

      When I tried to implement your code to do this, I get the following error: Can't locate object method "pnotes" via package "POST_MAX" (perhaps you forgot to load "POST_MAX"?)
      package MyApacheHandler; use base 'HTML::Mason::ApacheHandler'; sub prepare_request { my $self = shift; my $r = shift; my $post_max = 100; Apache::Request->instance( $r, POST_MAX => $post_max ); return $self->SUPER::prepare_request( $r, @_ ); } 1;
      In the autohandler
      <%init> use MyApacheHandler; my $apr = MyApacheHandler::prepare_request($r,POST_MAX => 1); </%init>
      Any idea why I get this error?

      Update: This is a newbie error and I solved it myself :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://328762]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2023-11-30 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?