private Duration determineDelayDuration ( HttpResponse response ) { int code = response . statusCode ( ) ; // Response will not have a retry-after-ms header. if ( code != HttpResponseStatus . TOO_MANY_REQUESTS . code ( ) && code != HttpResponseStatus . SERVICE_UNAVAILABLE . code ( ) ) { return this . delayDuration ; } String retryHeader = response . headerValue ( RETRY_AFTER_MS_HEADER ) ; // Retry header is missing or empty, return the default delay duration. if ( retryHeader == null || retryHeader . isEmpty ( ) ) { return this . delayDuration ; } // Use the response delay duration, the server returned it for a reason. return Duration . ofMillis ( Integer . parseInt ( retryHeader ) ) ; }
Determines the delay duration that should be waited before retrying .