如何在Tomcat 6中禁用Transfer-Encoding [英] How do disable Transfer-Encoding in Tomcat 6

查看:1911
本文介绍了如何在Tomcat 6中禁用Transfer-Encoding的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Tomcat 6.0.29服务器和JDK 1.6上运行的Web应用程序。

I have a web application running on Tomcat 6.0.29 server and JDK 1.6.

当我将响应发送到客户端时,Tomcat发送

When I send the response to the client, Tomcat sends

Transfer-Encoding: chunked 



当响应大小> 8KB时,在标题中

。对于回复< 8KB,发送

in the headers when the response size is > 8KB. For responses < 8KB, it sends

Content-Length : 

我知道 Chunked encoding 是处理批量响应的首选方式,但是我们的客户不想更改他们的代码(因为它分布在整个服务器上)。

I understand that Chunked encoding is the preferred way to handle bulk responses, however our clients do not want to change their code (as it is distributed all across the servers).

如何在Tomcat中禁用Chunked编码?

How can I disable Chunked encoding in Tomcat?

我可以在Tomcat中禁用HTTP / 1.1并启用HTTP / 1.0(不知道我该怎么做)

I could Disable HTTP/1.1 in Tomcat and enable HTTP/1.0 (not sure how I can do this)

我尝试了以下操作但没有成功:

I tried the following with no success:


  1. server.xml中的Connector标签中,我设置 bufferSize =65536

Connector port="8080" protocol="HTTP/1.1"
       connectionTimeout="20000"
       bufferSize="65536" socketBuffer="65536"
       redirectPort="8443" /&gt;


  • 在server.xml中使用NIOConnector并进行以下配置:

  • Using NIOConnector in server.xml with following configuration:

    <Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
           connectionTimeout="20000"
           socket.directBuffer="false"
           socket.rxBufSize="25188"
           socket.txBufSize="43800"
           socket.appReadBufSize="32768"
           socket.appWriteBufSize="32768"
           socket.bufferPool="500"
           socket.bufferPoolSize="100000000"
           socket.processorCache="500"
           socket.keyCache="500"
           socket.eventCache="500"
           socket.tcpNoDelay="false"
           socket.soKeepAlive="true"
           socket.soTimeout="5000"
           redirectPort="8443" />
    



  • 推荐答案

    我能让它工作的唯一方法是在响应时设置BufferSize。

    The only way I could get it working is by setting the BufferSize on response.

    response.setBufferSize()设置响应大小的 Content-Length 标头。一旦响应大小超出bufferSize,它将回退到 Transfer-Encoding:Chunked
    缓冲区大小应设置为适当的值。将其设置为更高的值将在刷新之前缓冲内存中的所有响应。因此,该值应设置为乐观的大小。

    response.setBufferSize() sets the Content-Length header of the response size. Once the response size goes beyond the bufferSize it would fallback to Transfer-Encoding: Chunked. The buffer size should be set to an appropriate value. Setting it to a higher value would buffer all of the response in memory before flushing it. So the value should be set to an optimistic size.

    我的客户很少依赖 Content-Length 响应头。为了向后兼容,我必须设置它。默认情况下,Tomcat缓冲区大小设置为8K(我认为对于Weblogic / Websphere,这是32K字节)。

    Few of my clients are depending on Content-Length response header. I have to set this for backward compatibility. By default Tomcat buffer size is set to 8K (I think for Weblogic/Websphere this is 32K bytes).

    这篇关于如何在Tomcat 6中禁用Transfer-Encoding的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆