Package kong.unirest.core
Class RetryStrategy.Standard
java.lang.Object
kong.unirest.core.RetryStrategy.Standard
- All Implemented Interfaces:
RetryStrategy
- Enclosing interface:
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface kong.unirest.core.RetryStrategy
RetryStrategy.Standard -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGet the max number of times the Unirest should retry responses before giving up and allowing a final returnlonggetWaitTime(HttpResponse response) Get the number of milliseconds the system should wait before retrying.booleanisRetryable(HttpResponse response) Checks to see if the response is retryableprivate static longprotected LongparseToMillies(String value) private static LongtryAsDateTime(String value) trySeconds(String s) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface kong.unirest.core.RetryStrategy
waitFor
-
Field Details
-
RETRY_CODES
-
RETRY_AFTER
- See Also:
-
maxAttempts
private final int maxAttempts
-
-
Constructor Details
-
Standard
public Standard(int maxAttempts)
-
-
Method Details
-
isRetryable
Description copied from interface:RetryStrategyChecks to see if the response is retryable- Specified by:
isRetryablein interfaceRetryStrategy- Parameters:
response- the last response- Returns:
- a bool indicating if the request should be retried
-
getWaitTime
Description copied from interface:RetryStrategyGet 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:
getWaitTimein interfaceRetryStrategy- Parameters:
response- the last response- Returns:
- millies
-
parseToMillies
-
getMaxAttempts
public int getMaxAttempts()Description copied from interface:RetryStrategyGet the max number of times the Unirest should retry responses before giving up and allowing a final return- Specified by:
getMaxAttemptsin interfaceRetryStrategy- Returns:
- the max attempts
-
tryAsDateTime
-
trySeconds
-
parse
-