org.apache.hc.client5.http

## Interface HttpRequestRetryStrategy

- All Known Implementing Classes:
    DefaultHttpRequestRetryStrategy

      @Contract(threading=STATELESS)
      public interface HttpRequestRetryStrategy

  Strategy interface that allows API users to plug in their own logic to control whether or not a retry should automatically be done, how many times it should be done and so on.
  Since:
    5.0

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default TimeValue` | `getRetryInterval(HttpRequest request, IOException exception, int execCount, HttpContext context)` Determines the retry interval between subsequent retries.
    `TimeValue` | `getRetryInterval(HttpResponse response, int execCount, HttpContext context)` Determines the retry interval between subsequent retries.
    `boolean` | `retryRequest(HttpRequest request, IOException exception, int execCount, HttpContext context)` Determines if a method should be retried after an I/O exception occurred during execution.
    `boolean` | `retryRequest(HttpResponse response, int execCount, HttpContext context)` Determines if a method should be retried given the response from the target server.

- - ### Method Detail

    - #### retryRequest

          boolean retryRequest(HttpRequest request,
                               IOException exception,
                               int execCount,
                               HttpContext context)

      Determines if a method should be retried after an I/O exception occurred during execution.
      Parameters:
        `request` - the request failed due to an I/O exception
        `exception` - the exception that occurred
        `execCount` - the number of times this method has been unsuccessfully executed
        `context` - the context for the request execution
      Returns:
        `true` if the request should be retried, `false` otherwise

    - #### retryRequest

          boolean retryRequest(HttpResponse response,
                               int execCount,
                               HttpContext context)

      Determines if a method should be retried given the response from the target server.
      Parameters:
        `response` - the response from the target server
        `execCount` - the number of times this method has been unsuccessfully executed
        `context` - the context for the request execution
      Returns:
        `true` if the request should be retried, `false` otherwise

    - #### getRetryInterval

          default TimeValue getRetryInterval(HttpRequest request,
                                             IOException exception,
                                             int execCount,
                                             HttpContext context)

      Determines the retry interval between subsequent retries.
      Parameters:
        `request` - the request failed due to an I/O exception
        `exception` - the exception that occurred
        `execCount` - the number of times this method has been unsuccessfully executed
        `context` - the context for the request execution
      Returns:
        the retry interval between subsequent retries

    - #### getRetryInterval

          TimeValue getRetryInterval(HttpResponse response,
                                     int execCount,
                                     HttpContext context)

      Determines the retry interval between subsequent retries.
      Parameters:
        `response` - the response from the target server
        `execCount` - the number of times this method has been unsuccessfully executed
        `context` - the context for the request execution
      Returns:
        the retry interval between subsequent retries

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