code: public Response reliableRequest(final Request request, final int[] retryCodes, int retries,
                                      final long delayMillis) {
          lastRequest = request;
          Response response = null;
          while (retries > 0) {
              response = makeRequest(request);
  
              if (!shouldRetry(response, retryCodes)) {
                  break;
              }
  
              try {
                  Thread.sleep(delayMillis);
              } catch (final InterruptedException e) {
                  // Delay failed, continue
              }
  
              // Decrement retries
              retries--;
          }
  
          lastResponse = response;
  
          return response;
      }
docs: Make a request.
  
  @param request request to make
  @param retryCodes codes used for retries
  @param retries max number of retries
  @param delayMillis delays between retries
  @return Response of the HTTP request