Package org.apache.http.client.utils
Class HttpClientUtils
- java.lang.Object
-
- org.apache.http.client.utils.HttpClientUtils
-
public class HttpClientUtils extends java.lang.ObjectConvenience methods for closing response and client objects.- Since:
- 4.2
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcloseQuietly(HttpClient httpClient)Unconditionally close a httpClient.static voidcloseQuietly(CloseableHttpResponse response)Unconditionally close a response.static voidcloseQuietly(HttpResponse response)Unconditionally close a response.
-
-
-
Method Detail
-
closeQuietly
public static void closeQuietly(HttpResponse response)
Unconditionally close a response.Example Code:
HttpResponse httpResponse = null; try { httpResponse = httpClient.execute(httpGet); } catch (Exception e) { // error handling } finally { HttpClientUtils.closeQuietly(httpResponse); }- Parameters:
response- the HttpResponse to release resources, may be null or already closed.- Since:
- 4.2
-
closeQuietly
public static void closeQuietly(CloseableHttpResponse response)
Unconditionally close a response.Example Code:
HttpResponse httpResponse = null; try { httpResponse = httpClient.execute(httpGet); } catch (Exception e) { // error handling } finally { HttpClientUtils.closeQuietly(httpResponse); }- Parameters:
response- the HttpResponse to release resources, may be null or already closed.- Since:
- 4.3
-
closeQuietly
public static void closeQuietly(HttpClient httpClient)
Unconditionally close a httpClient. Shuts down the underlying connection manager and releases the resources.Example Code:
HttpClient httpClient = HttpClients.createDefault(); try { httpClient.execute(request); } catch (Exception e) { // error handling } finally { HttpClientUtils.closeQuietly(httpClient); }- Parameters:
httpClient- the HttpClient to close, may be null or already closed.- Since:
- 4.2
-
-