Tomcat 7 ,Spring rest 模板应用程序在浏览器中产生 err_invalid_chunked_encoding [英] Tomcat 7 , Spring rest template application producing err_invalid_chunked_encoding in browser

查看:50
本文介绍了Tomcat 7 ,Spring rest 模板应用程序在浏览器中产生 err_invalid_chunked_encoding的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Tomcat 7 ,Spring 4.2 'RestController' REST API 实现,它似乎为返回 JSON 响应的少数 API 调用生成 'ERR_INVALID_CHUNKED_ENCODING'.

I have a Tomcat 7 , Spring 4.2 'RestController' implementation of REST API which seems to produce 'ERR_INVALID_CHUNKED_ENCODING' for few API calls on returning a JSON response.

它与创建 ResponseEntity 的代码相同.但是对于少数 API 调用,"Content-Length" 设置正确,其他调用 "Transfer-Encoding" 设置为分块.

It is the same code that creates a ResponseEntity. But for few API calls the "Content-Length" is set properly and other calls the "Transfer-Encoding" is set as Chunked.

private CacheControl cacheControl = CacheControl.noStore().mustRevalidate();    

protected <T> ResponseEntity<TNRestResponse<T>> createEntity(TNRestResponse<T> res) {
        return ResponseEntity.ok().cacheControl(cacheControl).body(res);
}

奇怪的部分是创建 ERR_INVALID_CHUNKED_ENCODING 的同一个 API 调用的响应似乎在另一个环境中工作正常.唯一的区别是客户端和服务在有问题的场景中运行在同一台服务器上.

The weird part is the response for the same API call that creates ERR_INVALID_CHUNKED_ENCODING seems to work fine in another environment. The only difference is the client and service is running in the same server in the problematic scenario.

已经尝试过的解决方案是手动设置 Content-Length ,这似乎导致客户端过早结束文件.JSON 长度只有大约 468 个字符,但客户端只收到 409 个字符,即使服务器日志显示已发送完整响应并且连接已关闭.

The solution already tried is to set the Content-Length manually which seems to result to premature end of file on the client.The JSON length is only around 468 characters but client receives only 409 characters , even though server logs shows that the full response has been sent and connection is closed.

我们对这个问题的解决方案很迷茫,因为它是相同的代码在不同的环境中表现得很奇怪.我试图检查两个tomcat上server.xml中的压缩设置.但一切看起来都很好.

We are so lost at the solution for this problem because it is the same code acting strangely in different environment.I tried to check the compression settings in server.xml on both the tomcat.But everything looks fine.

也在 IE 和 Chrome 中禁用代理设置.

Also disabled the proxy setting in both IE and chrome.

任何有用的输入或见解真的很好吗?提前致谢.

Any helpful inputs or insights would be really good ? Thanks in advance.

推荐答案

请按照以下步骤操作:

1) 转到您操作系统的控制面板 > Internet 选项 > 连接 >LAN 设置或您的浏览器设置.

1) Go to your OS's Control panel > internet options > Connections > LAN Settings or to your browser settings.

2) 取消选择 LAN 或浏览器的使用代理".

2) Deselect "Use Proxy" for your LAN or for your browser.

CHR_INVALIDEN_INVALID

原答案

另一个原始答案

这篇关于Tomcat 7 ,Spring rest 模板应用程序在浏览器中产生 err_invalid_chunked_encoding的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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