Java Spring MVC代理响应内容长度失败

Java Spring MVC代理响应内容长度失败,java,spring-mvc,http-proxy,transfer-encoding,http-content-length,Java,Spring Mvc,Http Proxy,Transfer Encoding,Http Content Length,我在SpringMVC服务中编写了一个代理,它将客户端通过特定格式发出的任何请求传递给相应的服务。这工作正常,但存在一些问题。这是我的密码 SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); InetSocketAddress address = new InetSocketAddress(this.serviceUrl, Integer.parseInt(t

我在SpringMVC服务中编写了一个代理,它将客户端通过特定格式发出的任何请求传递给相应的服务。这工作正常,但存在一些问题。这是我的密码

        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        InetSocketAddress address = new InetSocketAddress(this.serviceUrl, Integer.parseInt(this.servicePort));
        Proxy proxy = new Proxy(Proxy.Type.HTTP, address);
        factory.setProxy(proxy);
        factory.setBufferRequestBody(true);
        RestTemplate restTemplate = new RestTemplate();
        restTemplate.setRequestFactory(factory);

        ResponseEntity<byte[]> responseEntity = restTemplate.exchange(uri, method, new HttpEntity<Object>(body,headers), byte[].class);
        return responseEntity;
如果目标响应为

Access-Control-Allow-Headers:X-Requested-With
Access-Control-Allow-Methods:GET
Access-Control-Allow-Origin:*
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Type:application/json
Date:Thu, 26 Nov 2015 06:54:14 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=100
Pragma:no-cache
Server:Apache/2.4.9 (Unix) PHP/5.5.23
Transfer-Encoding:chunked
X-Powered-By:PHP/5.5.23
我能找到的唯一区别是传输编码:分块和内容长度

代理服务没有将整个数据传输到客户端。相反,它在获得一定数量的数据后会中断


如果有人知道我该怎么解决它。我确信这是代理配置的问题。但无法修复。

这工作正常,但存在一些问题。实际的问题是什么?代理没有将完整的数据从目标发送到客户端。
Access-Control-Allow-Headers:X-Requested-With
Access-Control-Allow-Methods:GET
Access-Control-Allow-Origin:*
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Type:application/json
Date:Thu, 26 Nov 2015 06:54:14 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=100
Pragma:no-cache
Server:Apache/2.4.9 (Unix) PHP/5.5.23
Transfer-Encoding:chunked
X-Powered-By:PHP/5.5.23