问题
Is there a maximum length (not default value) for URIs in Tomcat and in Grizzly (GlassFish 3)?
I want to create a RESTful API which should be able to receive big GET requests.
回答1:
In Tomcat it's configureable as maxHttpHeaderSize
attribute of the HTTP connector element in server.xml
. Its default value is 8192 bytes (8KB). That's about the same amount of unencoded ASCII characters. As Glassfish v3 uses Tomcat under the hood, the configuration setting is the same. Grizzly is just a HTTP connector implementation which can be used in both Glassfish and Tomcat. The abstract configuration should not depend on the HTTP connector implementation used.
That said, there's also another limitation to take account with, namely the one at client side / proxy side. Even the HTTP 1.1 specification warns about this, here's an extract of chapter 3.2.1:
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.
The limit is in MSIE and Safari about 2KB, in Opera about 4KB and in Firefox about 8KB. We may thus assume that 8KB is the maximum possible length and that 2KB is a more affordable length to rely on at the server side and that 255 bytes is the safest length to assume that the entire URL will come in.
来源:https://stackoverflow.com/questions/2063666/maximum-uri-length-in-grizzly-glassfish-and-tomcat