org.apache.hc.client5.http.impl

## Class DefaultHttpRequestRetryHandler

- java.lang.Object
- - org.apache.hc.client5.http.impl.DefaultHttpRequestRetryHandler

All Implemented Interfaces:
  HttpRequestRetryHandler

    @Contract(threading=STATELESS)
    public class DefaultHttpRequestRetryHandler
    extends Object
    implements HttpRequestRetryHandler

The default `HttpRequestRetryHandler` used by request executors.

Since:
  4.0

### Field Summary

Fields
`static DefaultHttpRequestRetryHandler` `INSTANCE`

### Constructor Summary

Constructors
`` `DefaultHttpRequestRetryHandler()` Create the request retry handler with a retry count of 3, requestSentRetryEnabled false and using the following list of non-retriable IOException classes: InterruptedIOException UnknownHostException ConnectException SSLException
`` `DefaultHttpRequestRetryHandler(int retryCount)` Create the request retry handler using the following list of non-retriable IOException classes: InterruptedIOException UnknownHostException ConnectException ConnectionClosedException SSLException
`protected` `DefaultHttpRequestRetryHandler(int retryCount, Class<? extends IOException>... clazzes)` Create the request retry handler using the specified IOException classes

### Method Summary

Methods
`int` `getRetryCount()`
`protected boolean` `handleAsIdempotent(org.apache.hc.core5.http.HttpRequest request)`
`boolean` `retryRequest(org.apache.hc.core5.http.HttpRequest request, IOException exception, int executionCount, org.apache.hc.core5.http.protocol.HttpContext context)` Used `retryCount` and `requestSentRetryEnabled` to determine if the given method should be retried.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### INSTANCE

    public static final DefaultHttpRequestRetryHandler INSTANCE

### Constructor Detail

#### DefaultHttpRequestRetryHandler

    @SafeVarargs
    protected DefaultHttpRequestRetryHandler(int retryCount,
                                              Class<? extends IOException>... clazzes)

Create the request retry handler using the specified IOException classes

Parameters:
  `retryCount` - how many times to retry; 0 means no retries
  `clazzes` - the IOException types that should not be retried
Since:
  5.0

#### DefaultHttpRequestRetryHandler

    public DefaultHttpRequestRetryHandler(int retryCount)

Create the request retry handler using the following list of non-retriable IOException classes:

- InterruptedIOException
- UnknownHostException
- ConnectException
- ConnectionClosedException
- SSLException

Parameters:
  `retryCount` - how many times to retry; 0 means no retries
Since:
  5.0

#### DefaultHttpRequestRetryHandler

    public DefaultHttpRequestRetryHandler()

Create the request retry handler with a retry count of 3, requestSentRetryEnabled false and using the following list of non-retriable IOException classes:

- InterruptedIOException
- UnknownHostException
- ConnectException
- SSLException

### Method Detail

#### retryRequest

    public boolean retryRequest(org.apache.hc.core5.http.HttpRequest request,
                       IOException exception,
                       int executionCount,
                       org.apache.hc.core5.http.protocol.HttpContext context)

Used `retryCount` and `requestSentRetryEnabled` to determine if the given method should be retried.

Specified by:
  `retryRequest` in interface `HttpRequestRetryHandler`
Parameters:
  `request` - request failed die to an I/O exception.
  `exception` - the exception that occurred
  `executionCount` - the number of times this method has been unsuccessfully executed
  `context` - the context for the request execution
Returns:
  `true` if the method should be retried, `false` otherwise

#### getRetryCount

    public int getRetryCount()

Returns:
  the maximum number of times a method will be retried

#### handleAsIdempotent

    protected boolean handleAsIdempotent(org.apache.hc.core5.http.HttpRequest request)

Since:
  4.2