2

I have a Jersey-Application that proxies a request to an internal application, which should be out of direct access.

@GET
@Path("/path")
public static Response get(
        @Context UriInfo uriinfo,
        @Context HttpHeaders httpHeaders,
        byte[] body
        ) throws Exception{

//call the internal application
Response response = get(url, uriinfo, httpHeaders, body, HttpMethod.GET);

ResponseBuilder rb = Response.
                status(response.getStatusCode()).
                entity(response.getResponseStream());

//set all headers from response
for(header : response.getResponseHeaders()){
    rb.header(...);
}

Response r = rb.build();
//checking headers here, does NOT contain any Content-Length header
return r;

In the response, that comes from the internal application, there's the Transfer-Encoding = chunked header set. This is alright so far.

Now, the response that is sent to the client also contains the Content-Length header set, presumably by Jersey itself on the outgoing response. When I check the headers before I sent them to the client, all headers are set correctly like in the response from the internal app.

The Content-Length header causes the client to not interpret the response correctly, as there should be either Content-Length or Transfer-Encoding set, as stated here.

How can I prevent Jersey from setting the Content-Length header, if I already have the Transfer-Encoding set?

ulrich
  • 1,431
  • 3
  • 17
  • 46
  • Hi, just checking to see if you got any resolution to this issue? Cheers, Rob. – Rob Bygrave Nov 03 '16 at 04:29
  • @Rob Not the way, I expected to do it. My workaround was to remove the `Transfer-Encoding` header before sending the response to the client, which works for me so far. – ulrich Nov 03 '16 at 20:14

0 Answers0