private ClientResponse translate(final ClientRequest requestContext,
final HttpResponseStatus status,
final HttpResponseHeaders headers,
final NonBlockingInputStream entityStream) {
final ClientResponse responseContext = new ClientResponse(new Response.StatusType() {
@Override
public int getStatusCode() {
return status.getStatusCode();
}
@Override
public Response.Status.Family getFamily() {
return Response.Status.Family.familyOf(status.getStatusCode());
}
@Override
public String getReasonPhrase() {
return status.getStatusText();
}
}, requestContext);
for (Map.Entry<String, List<String>> entry : headers.getHeaders().entrySet()) {
for (String value : entry.getValue()) {
responseContext.getHeaders().add(entry.getKey(), value);
}
}
responseContext.setEntityStream(entityStream);
return responseContext;
}