Open
Description
Hello. I have a question about feign.Response. When I look at the following code, there is code that does not return a Response object under certain conditions.
private static Response disconnectResponseBodyIfNeeded(Response response) throws IOException {
final boolean shouldDisconnectResponseBody = response.body() != null
&& response.body().length() != null
&& response.body().length() <= MAX_RESPONSE_BUFFER_SIZE;
if (!shouldDisconnectResponseBody) {
return response;
}
try {
final byte[] bodyData = Util.toByteArray(response.body().asInputStream());
return response.toBuilder().body(bodyData).build();
} finally {
ensureClosed(response.body());
}
}
For example, in a Spring Framework-based MVC application, when there is an error response, the 'Content-Length' header is missing, and in such cases, the resource is not released. Is there a reason for the existence of this code, and could it be code that is not necessary?