Nice question, Ryszard.

I would subclass CGI::Application and reimplement the query method:

sub query { my $self = shift; my ($query) = @_; # We're only allowed to set a new query object if one does not yet e +xist! unless (exists($self->{__QUERY_OBJ})) { my $new_query_obj; # If data is provided, set it! Otherwise, create a new one. if (defined($query) && $query->isa('CGI')) { $new_query_obj = $query; } else { $CGI::POST_MAX=1024 * 100; # max 100K posts $new_query_obj = CGI->new(); } $self->{__QUERY_OBJ} = $new_query_obj; } return $self->{__QUERY_OBJ}; }

Beware, the code isn't tested. The new method could also use a parameter passed during start up:

my $webapp = App->new( TMPL_PATH => 'App/', PARAMS => { 'max_upload_size' => 100 } );

Then you could check this parameter and act accordingly inside your reimplemented method. Another solution could be creating a new CGI object (with POST_MAX set properly) and passing it to application init; C::A will recognize the object and use it; here is an excerpt from the man page:

QUERY - This optional parameter allows you to specify an already-created CGI.pm query object. Under normal use, CGI::Application will instantiate its own CGI.pm query object. Under certain conditions, it might be useful to be able to use one which has already been created.

Hope this helps. Ciao, Valerio


In reply to Re: CGI upload limit by valdez
in thread CGI upload limit by Ryszard

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.