Jersey框架资源响应问题分块编码数据

时间:2018-07-23 11:52:34

标签: java http docker jersey http-headers

我正在使用Jersey框架开发一个应用程序,该应用程序充当Docker HTTP API的代理。我能够将图像成功上传到Docker,但是我无法毫无错误地将响应从Docker转发到客户端。我相信这与响应中的Transfer-Encoding = [chunked]标头有关。

回复

* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> POST /proxy/images/load HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 127.0.0.1:8080
> Accept: */*
> Content-Type: application/octet-stream
> Content-Length: 477637632
> Expect: 100-continue
> 
< HTTP/1.1 100 
< HTTP/1.1 200 
< Transfer-Encoding: chunked
< Docker-Experimental: false
< Api-Version: 1.26
< Server: Docker/1.13.1 (linux)
< Date: Mon, 23 Jul 2018 11:20:14 GMT
< Content-Type: application/json
< Content-Length: 54
< 
* Problem (2) in the Chunked-Encoded data
* Closing connection 0
curl: (56) Problem (2) in the Chunked-Encoded data

代码

@POST 
@Path("/load2")
//@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response loadimages(byte[] input, @Context UriInfo uriInfo) {             
    WebTarget webTarget = ClientBuilder.newClient().target("http://127.0.0.1:5555/images").path("load");    
    Response response   = webTarget.request(MediaType.APPLICATION_JSON).post(Entity.entity(input, MediaType.APPLICATION_OCTET_STREAM));
    return response;
}

0 个答案:

没有答案