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

I am using GET with textarea tag as part of a form to log windows error. Text exceeding 1.5 kb gets truncated such as the DrWatson logs generated by W2k & NT. How should I change my script so that no truncation occurs? Or does the problem/solution lie w/Apache config? I not familiar w/using POST but any pointers will be appreciated.
  • Comment on My form can only hold 1.5KB of text how to increase this limit?

Replies are listed 'Best First'.
Re: My form can only hold 1.5KB of text how to increase this limit?
by maverick (Curate) on Aug 02, 2001 at 01:49 UTC
    GET and POST differ in a couple of ways. POST's size limit is much larger than GET (as you've already seen). GET paramaters apear at the end of the URL after the ? while POST parameters are hidden. If your CGI script (which I'm assuming is in Perl), is using CGI.pm then you shouldn't have to change anything in your CGI code. All you should have to do is change method=GET to method=POST (or add method=POST) to the <form> tag.
Re: My form can only hold 1.5KB of text how to increase this limit?
by mischief (Hermit) on Aug 02, 2001 at 15:10 UTC

    From RFC 2068 (HTTP/1.1):

    The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15).

    Apache allows you to change this. From http://httpd.apache.org/docs/mod/core.html#limitrequestline:

    The LimitRequestLine directive allows the server administrator to reduce the limit on the allowed size of a client's HTTP request-line below the normal input buffer size compiled with the server.

    This page says that Apache's limit is 8190 by default, so I don't think it's the server. In my experience, a 1024 byte limit is generally because of the browser. Are you using IE? I seem to remember having some unexpected problems once because I was testing in Netscape and IE users couldn't use the form properly.

    So, as has already been suggested, use POST instead.

    update: wait - you said 1.5K of text. I still think it's the browser though.

Re: My form can only hold 1.5KB of text how to increase this limit?
by little (Curate) on Aug 02, 2001 at 17:19 UTC
    CGI.pm does allow you to set the maximum amount it will accept to avoid server attacks with large remittances. You can set this as described in the docs. See the cite:

    Another possible attack is for the remote user to force CGI.pm to accept a huge file upload. CGI.pm will accept the upload and store it in a temporary directory even if your script doesn't expect to receive an uploaded file. CGI.pm will delete the file automatically when it terminates, but in the meantime the remote user may have filled up the server's disk space, causing problems for other programs.

    The best way to avoid denial of service attacks is to limit the amount of memory, CPU time and disk space that CGI scripts can use. Some Web servers come with built-in facilities to accomplish this. In other cases, you can use the shell limit or ulimit commands to put ceilings on CGI resource usage.

    CGI.pm also has some simple built-in protections against denial of service attacks, but you must activate them before you can use them. These take the form of two global variables in the CGI name space:

    $CGI::POST_MAX

    If set to a non-negative integer, this variable puts a ceiling on the size of POSTings, in bytes. If CGI.pm detects a POST that is greater than the ceiling, it will immediately exit with an error message. This value will affect both ordinary POSTs and multipart POSTs, meaning that it limits the maximum size of file uploads as well. You should set this to a reasonably high value, such as 1 megabyte.

    $CGI::DISABLE_UPLOADS

    If set to a non-zero value, this will disable file uploads completely. Other fill-out form values will work as usual.


    So, if your server does have alimit set, ask the Admin, how to ship around the limit.
    But before you might try the example form cgi.pm's docs:
    1. On a script-by-script basis Set the variable at the top of the script, right after the ``use'' sta +tement: use CGI qw/:standard/; use CGI::Carp 'fatalsToBrowser'; $CGI::POST_MAX=1024 * 100; # max 100K posts

    Have a nice day
    All decision is left to your taste