Class RetryStrategy.Standard

java.lang.Object
kong.unirest.core.RetryStrategy.Standard
All Implemented Interfaces:
RetryStrategy
Enclosing interface:
RetryStrategy

public static class RetryStrategy.Standard extends Object implements RetryStrategy
A standard implementation of the RetryStrategy which follows spec based Retry-After logic - Will attempt a retry on any 301, 429, 503, or 529 response which is accompanied by a Retry-After header. - Retry-After can be either date or seconds based see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
  • Field Details

    • RETRY_CODES

      private static final Set<Integer> RETRY_CODES
    • RETRY_AFTER

      private static final String RETRY_AFTER
      See Also:
    • maxAttempts

      private final int maxAttempts
  • Constructor Details

    • Standard

      public Standard(int maxAttempts)
  • Method Details

    • isRetryable

      public boolean isRetryable(HttpResponse response)
      Description copied from interface: RetryStrategy
      Checks to see if the response is retryable
      Specified by:
      isRetryable in interface RetryStrategy
      Parameters:
      response - the last response
      Returns:
      a bool indicating if the request should be retried
    • getWaitTime

      public long getWaitTime(HttpResponse response)
      Description copied from interface: RetryStrategy
      Get the number of milliseconds the system should wait before retrying. A value less than 1 will result in the termination of the retry loop
      Specified by:
      getWaitTime in interface RetryStrategy
      Parameters:
      response - the last response
      Returns:
      millies
    • parseToMillies

      protected Long parseToMillies(String value)
    • getMaxAttempts

      public int getMaxAttempts()
      Description copied from interface: RetryStrategy
      Get the max number of times the Unirest should retry responses before giving up and allowing a final return
      Specified by:
      getMaxAttempts in interface RetryStrategy
      Returns:
      the max attempts
    • tryAsDateTime

      private static Long tryAsDateTime(String value)
    • trySeconds

      private static Optional<Long> trySeconds(String s)
    • parse

      private static long parse(String s)