java – Problem with URL too long


I'm trying to pass a URL by GET and the server is returning error 404 because the URL is too long (I'm passing an XML through the URL).

I already tried to add the variables MaxFieldLength with 1677721 and MaxRequestBytes with 1677721 in the Windows registry, as per the link below:

Note: The operating system is Windows Server 2012.


This answer is a partial translation of a SOzão reference

Short answer: keep the URL to 2000 bytes

Keeping it below 2k, the URL will work in almost any condition.

Long answer: first, the patterns…

RFC 2616 (Hypertext Transfer Protocol HTTP/1.1) section 3.2.1 says:

The HTTP protocol does not place any a priori limit on the length of
the 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 the URI is longer than the server can handle (see section 10.4.15).

and also:

Note: Servers ought to be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations might not properly support these lengths.

In summary, the HTTP protocol should not impose a limit on the length of a URI, and should be able to resolve GETs of any size from forms. If the server cannot resolve the URI of the given length, it should return a 414.

… it's reality.

There is a search on whose summary is:

Extremely long URLs are usually a mistake. URLs over 2,000 characters will not work in the most popular web browsers. Don't use them if you intend your site to work for the majority of Internet users.

Which in short says that URLs longer than 2000 characters will not work in most browsers.

In other words, even if you configure the server for larger requests, you will still probably need to do them by means other than a browser, such as cURL and the like.

Scroll to Top