### Question:
DefaultHttpRequestRetryStrategy implements HttpRequestRetryStrategy { @Override public TimeValue getRetryInterval( final HttpResponse response, final int execCount, final HttpContext context) { Args.notNull(response, "response"); final Header header = response.getFirstHeader(HttpHeaders.RETRY_AFTER); TimeValue retryAfter = null; if (header != null) { final String value = header.getValue(); try { retryAfter = TimeValue.ofSeconds(Long.parseLong(value)); } catch (final NumberFormatException ignore) { final Date retryAfterDate = DateUtils.parseDate(value); if (retryAfterDate != null) { retryAfter = TimeValue.ofMilliseconds(retryAfterDate.getTime() - System.currentTimeMillis()); } } if (TimeValue.isPositive(retryAfter)) { return retryAfter; } } return this.defaultRetryInterval; } protected  DefaultHttpRequestRetryStrategy(
            final int maxRetries,
            final TimeValue defaultRetryInterval,
            final Collection<Class<? extends IOException>> clazzes,
            final Collection<Integer> codes);  DefaultHttpRequestRetryStrategy(
            final int maxRetries,
            final TimeValue defaultRetryInterval);  DefaultHttpRequestRetryStrategy(); @Override boolean retryRequest(
            final HttpRequest request,
            final IOException exception,
            final int execCount,
            final HttpContext context); @Override boolean retryRequest(
            final HttpResponse response,
            final int execCount,
            final HttpContext context); @Override TimeValue getRetryInterval(
            final HttpResponse response,
            final int execCount,
            final HttpContext context); static final DefaultHttpRequestRetryStrategy INSTANCE; }### Answer:
@Test public void testRetryAfterHeaderAsLong() throws Exception { final HttpResponse response = new BasicHttpResponse(503, "Oopsie"); response.setHeader(HttpHeaders.RETRY_AFTER, "321"); Assert.assertEquals(TimeValue.ofSeconds(321L), this.retryStrategy.getRetryInterval(response, 3, null)); }
@Test public void testRetryAfterHeaderAsDate() throws Exception { this.retryStrategy = new DefaultHttpRequestRetryStrategy(3, TimeValue.ZERO_MILLISECONDS); final HttpResponse response = new BasicHttpResponse(503, "Oopsie"); response.setHeader(HttpHeaders.RETRY_AFTER, DateUtils.formatDate(new Date(System.currentTimeMillis() + 100000L))); Assert.assertTrue(this.retryStrategy.getRetryInterval(response, 3, null).compareTo(TimeValue.ZERO_MILLISECONDS) > 0); }
@Test public void testRetryAfterHeaderAsPastDate() throws Exception { final HttpResponse response = new BasicHttpResponse(503, "Oopsie"); response.setHeader(HttpHeaders.RETRY_AFTER, DateUtils.formatDate(new Date(System.currentTimeMillis() - 100000L))); Assert.assertEquals(TimeValue.ofMilliseconds(1234L), this.retryStrategy.getRetryInterval(response, 3, null)); }
@Test public void testInvalidRetryAfterHeader() throws Exception { final HttpResponse response = new BasicHttpResponse(503, "Oopsie"); response.setHeader(HttpHeaders.RETRY_AFTER, "Stuff"); Assert.assertEquals(TimeValue.ofMilliseconds(1234L), retryStrategy.getRetryInterval(response, 3, null)); }