HttpClientUtils (Apache HttpClient 4.5.13 API)
Date: 2020-10-03

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.http.client.utils
Class HttpClientUtils

    java.lang.Object
      org.apache.http.client.utils.HttpClientUtils

    public class HttpClientUtils

extends Object

Convenience methods for closing response and client objects.

Since:
  4.2

Method Summary
`static void` | `closeQuietly(CloseableHttpResponse response)` Unconditionally close a response.
`static void` | `closeQuietly(HttpClient httpClient)` Unconditionally close a httpClient.
`static void` | `closeQuietly(org.apache.http.HttpResponse response)` Unconditionally close a response.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### closeQuietly

    public static void closeQuietly(org.apache.http.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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999–2020 The Apache Software Foundation. All rights reserved.