Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,12 @@ private constructor(
return executeWithRetries(request, requestOptions)
}

override fun close() {
httpClient.close()
}
override fun close() = httpClient.close()

private fun isRetryable(request: HttpRequest): Boolean {
private fun isRetryable(request: HttpRequest): Boolean =
// Some requests, such as when a request body is being streamed, cannot be retried because
// the body data aren't available on subsequent attempts.
return request.body?.repeatable() ?: true
}
request.body?.repeatable() ?: true

private fun setRetryCountHeader(request: HttpRequest, retries: Int) {
request.headers.removeAll("x-stainless-retry-count")
Expand Down Expand Up @@ -170,12 +167,11 @@ private constructor(
}
}

private fun shouldRetry(throwable: Throwable): Boolean {
private fun shouldRetry(throwable: Throwable): Boolean =
// Only retry IOException and OnebusawaySdkIoException, other exceptions are not intended to
// be
// retried.
return throwable is IOException || throwable is OnebusawaySdkIoException
}
throwable is IOException || throwable is OnebusawaySdkIoException

private fun getRetryBackoffMillis(retries: Int, response: HttpResponse?): Duration {
// About the Retry-After header:
Expand Down