本文介绍了Grizzly(GlassFish)和Tomcat中的最大URI长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Tomcat和Grizzly(GlassFish 3)中的URI的最大长度(非默认值)是多少?

Is there a maximum length (not default value) for URIs in Tomcat and in Grizzly (GlassFish 3)?

我想创建一个RESTful API,它应该是能够接收大的GET请求。

I want to create a RESTful API which should be able to receive big GET requests.

推荐答案

在Tomcat中,它可配置为 maxHttpHeaderSize <$ c $中元素的属性C> server.xml中。其默认值是8192字节(8KB)。这大约与未编码的ASCII字符数量相同。由于Glassfish v3使用Tomcat,配置设置相同。 Grizzly只是一个HTTP连接器实现,可用于Glassfish和Tomcat。抽象配置不应该依赖于所使用的HTTP连接器实现。

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.

也就是说,还需要考虑另一个限制,即客户端/代理端的限制。即使HTTP 1.1规范也对此提出警告,下面是:

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:

在MSIE和Safari中约为2KB,在Opera中约为4KB,在Firefox中约为8KB。因此,我们可以假设8KB是最大可能的长度,并且2KB是服务器端依赖的更合理的长度,并且255个字节是假定整个URL将进入的最安全长度。

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.

这篇关于Grizzly(GlassFish)和Tomcat中的最大URI长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 19:33
查看更多