Maximum URI length in Grizzly (GlassFish) and Tomcat

青春壹個敷衍的年華 提交于 2019-12-11 15:46:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!