Class RetryAfter

All Implemented Interfaces:
Serializable, Cloneable, Header, NameValuePair

@Header("Retry-After") public class RetryAfter extends BasicDateHeader
Represents a parsed Retry-After HTTP response header.

If an entity is temporarily unavailable, this instructs the client to try again later. Value could be a specified period of time (in seconds) or a HTTP-date.

Example

Retry-After: 120 Retry-After: Fri, 07 Nov 2014 23:59:59 GMT

RFC2616 Specification
The Retry-After response-header field can be used with a 503 (Service Unavailable) response to indicate how long the service is expected to be unavailable to the requesting client. This field MAY also be used with any 3xx (Redirection) response to indicate the minimum time the user-agent is asked wait before issuing the redirected request. The value of this field can be either an HTTP-date or an integer number of seconds (in decimal) after the time of the response.

Retry-After = "Retry-After" ":" ( HTTP-date | delta-seconds )

Two examples of its use are

Retry-After: Fri, 31 Dec 1999 23:59:59 GMT Retry-After: 120

In the latter example, the delay is 2 minutes.

See Also:
  • Constructor Details

    • RetryAfter

      public RetryAfter(String value)
      Constructor.
      Parameters:
      value - The header value.
      Must be an RFC-1123 formated string (e.g. "Sat, 29 Oct 1994 19:43:31 GMT") or an integer.
      Can be null.
    • RetryAfter

      public RetryAfter(ZonedDateTime value)
      Constructor.
      Parameters:
      value - The header value.
      Can be null.
    • RetryAfter

      public RetryAfter(Integer value)
      Constructor.
      Parameters:
      value - The header value.
      Can be null.
    • RetryAfter

      public RetryAfter(Supplier<?> value)
      Constructor with delayed value.

      Header value is re-evaluated on each call to getValue().

      Parameters:
      value - The supplier of the header value.
      Supplier must supply either Integer or ZonedDateTime objects.
      Can be null.
  • Method Details

    • of

      public static RetryAfter of(String value)
      Static creator.
      Parameters:
      value - The header value.
      Must be an RFC-1123 formated string (e.g. "Sat, 29 Oct 1994 19:43:31 GMT") or an integer.
      Can be null.
      Returns:
      A new header bean, or null if the name is null or empty or the value is null.
    • of

      public static RetryAfter of(ZonedDateTime value)
      Static creator.
      Parameters:
      value - The header value.
      Can be null.
      Returns:
      A new header bean, or null if the name is null or empty or the value is null.
    • of

      public static RetryAfter of(Integer value)
      Static creator.
      Parameters:
      value - The header value.
      Can be null.
      Returns:
      A new header bean, or null if the name is null or empty or the value is null.
    • of

      public static RetryAfter of(Supplier<?> value)
      Static creator with delayed value.

      Header value is re-evaluated on each call to getValue().

      Parameters:
      value - The supplier of the header value.
      Supplier must supply either Integer or ZonedDateTime objects.
      Can be null.
      Returns:
      A new header bean, or null if the name is null or empty or the value is null.
    • getValue

      public String getValue()
      Specified by:
      getValue in interface NameValuePair
      Overrides:
      getValue in class BasicDateHeader
    • asInteger

      Returns this header value as an integer.
      Returns:
      This header value as a integer, or an empty optional if value was null or not an integer.