Tomcat 7 , Spring rest template application producing err_invalid_chunked_encoding in browser

醉酒当歌 提交于 2019-12-23 09:18:08

问题


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.

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);
}

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.

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.

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.

Also disabled the proxy setting in both IE and chrome.

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


回答1:


Follow these steps:

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

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

ERR_INVALID_CHUNKED_ENCODING

Original answer

Another original answer



来源:https://stackoverflow.com/questions/49744379/tomcat-7-spring-rest-template-application-producing-err-invalid-chunked-encodi

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