直接アクセスできない内部アプリケーションへのリクエストをプロキシする Jersey-Application があります。
@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;
内部アプリケーションからの応答には、Transfer-Encoding = chunked
ヘッダー セットがあります。ここまでは大丈夫です。
現在、クライアントに送信されるContent-Length
応答には、発信応答でおそらく Jersey 自体によって設定されたヘッダーも含まれています。クライアントに送信する前にヘッダーを確認すると、内部アプリからの応答のように、すべてのヘッダーが正しく設定されています。
ヘッダーが原因で、クライアントはContent-Length
応答を正しく解釈できません。ここで説明されているように、どちらか Content-Length
またはTransfer-Encoding
設定されている必要があります。
Content-Length
Transfer-Encoding が既に設定されている場合、Jersey がヘッダーを設定できないようにするにはどうすればよいですか?