http://www.perlmonks.org?node_id=30474

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

hi fella monks, i currently doing a program where in you can modify html document via web browser. i don't think this a bug in my code, 'coz the error is "414 Request-URI Too Large". I am passing the modified string with a post method and as a parameter in my perl code. had anyone here experienced one of this? oh btw i'm using apache web server.

Replies are listed 'Best First'.
(Ovid) Re: 414 Request-URI Too Large
by Ovid (Cardinal) on Aug 31, 2000 at 09:53 UTC
    There are a couple of conditions that can cause this issue. One is a redirect URL prefix pointing to a suffix of itself. If you're doing any redirection, check for this.

    The other rare, but still more common, instance occurs when generating a get request which has too many characters for a geniune URL (typically 2048 to 4096 bytes). This means switching back to a post from a get. I see that you state that you are using a post method, so I would examine the raw HTTP headers to verify that your client isn't erroneously sending the request via the get method. Stranger things have been known to happen.

    Also, I don't know how to find this in Apache, but if you could find out the max length of requests and how to set this, it may help. CGI.pm can also throw an error if you exceed maximum post length, but I believe that it's just a simple die message and doesn't generate a 414. Probably generates a 5xx status code on the die.

    Cheers,
    Ovid

      414 means "URI is too large". Under Apache, this is a configurable limit, controlled by the LimitRequestLine configuration parameter. The maximum for this parameter appears to be 8190 by default, but even that can be hacked at compile time.

      The W3 specs do not provide a "minimum maximum" or a "maxiumum maximum" for the length of a URI, so you really are on your own to see what will work in any given situation. There's no theoretical reason why a 50 megabyte GET would be disallowed, so the common chatter of "you can't have a URI longer than mumbleK bytes" has no basis in reality, because the right answer is "well, it depends".

      -- Randal L. Schwartz, Perl hacker

        I met it with CGI::Ajax. It makes my form buggy. (Ajax outputs are in a random case). Meanwhile, my requests have all a small length and are post-ed ! it appends at the nth entry. i have to catch the error ...

      I've seen oddball behavior with POST once before: a client, who I won't mention, had a not-so-great firewall configured and managed by another vendor. The client was trying to post replies to questions on a message board on their website (which was hosted by the company I was working for at the time), but the replies kept getting cut off at 5K. It turns out the firewall itself was truncating the POST requests.... So it wouldn't surprise me one bit if a badly behaving proxy server were converting POSTs to GETs -- especially if it were a proxy designed to cache requests (since you can more readily cache the response to a GET than the response to a POST).

      Spud Zeppelin * spud@spudzeppelin.com

        Hi, Have anyone found solution for above problem? If so I am eager to know that, which helps me in resoving my bug. Thanks.
RE: 414 Request-URI Too Large
by Jouke (Curate) on Aug 31, 2000 at 11:06 UTC
    It looks like you issue an HTTP 'GET'. Try issuing an HTTP 'POST instead.

    Jouke Visser, Perl 'Adept'
RE: 414 Request-URI Too Large
by Anonymous Monk on Sep 03, 2000 at 22:00 UTC
    Sounds like the URI is longer than 256 characters. Make sure you are doing a POST, not a GET, because a lengthy request string will produce this error.