Files
spring-boot-rest/httpclient4/src/test/java/com/baeldung/httpclient/ResponseUtil.java
panos-kakos 8f49093d3f Java 15035 (#13421)
* [JAVA-15035] Created module httpclient4 and moved related code

* [JAVA-15035] Upgraded httpclient-simple to spring-boot-e

* [JAVA-15035] Moved modules to to right profiles

* [JAVA-15026] Upgraded headers code to apache 5.2 + moved code related to 4.5 to httpclient4 module

* [JAVA-14911] Final clean up for http-client module

---------

Co-authored-by: panagiotiskakos <panagiotis.kakos@libra-is.com>
2023-02-07 21:09:57 +05:30

27 lines
618 B
Java

package com.baeldung.httpclient;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import java.io.IOException;
public final class ResponseUtil {
private ResponseUtil() {
}
public static void closeResponse(CloseableHttpResponse response) throws IOException {
if (response == null) {
return;
}
try {
final HttpEntity entity = response.getEntity();
if (entity != null) {
entity.getContent().close();
}
} finally {
response.close();
}
}
}