rateLimitHost

fun OkHttpClient.Builder.rateLimitHost(httpUrl: HttpUrl, permits: Int, period: Long = 1, unit: TimeUnit = TimeUnit.SECONDS): OkHttpClient.Builder(source)

Deprecated

Use the version with kotlin.time APIs instead.

An OkHttp interceptor that handles given url host's rate limiting.

This uses Java Time APIs and is the legacy method, kept for compatibility reasons with existing extensions.

Examples:

httpUrl = "https://api.anime.com".toHttpUrl(), permits = 5, period = 1, unit = seconds => 5 requests per second to api.anime.com httpUrl = "https://cdn.thumbnails.com".toHttpUrl(), permits = 10, period = 2, unit = minutes => 10 requests per 2 minutes to cdn.thumbnails.com

Since

extension-lib 13

Parameters

httpUrl

HttpUrl The url host that this interceptor should handle. Will get url's host by using HttpUrl.host()

permits

Int Number of requests allowed within a period of units.

period

Long The limiting duration. Defaults to 1.

unit

TimeUnit The unit of time for the period. Defaults to seconds.


fun OkHttpClient.Builder.rateLimitHost(httpUrl: HttpUrl, permits: Int, period: Duration = 1.seconds): OkHttpClient.Builder(source)

Deprecated

Default rate limiting implementation is no longer provided. Source developers are now responsible for implementing their own rate limiting logic if desired, to prevent forks from bypassing it.

Replace with

this

An OkHttp interceptor that handles given url host's rate limiting.

Examples:

httpUrl = "https://api.anime.com".toHttpUrl(), permits = 5, period = 1.seconds => 5 requests per second to api.anime.com httpUrl = "https://cdn.thumbnails.com".toHttpUrl(), permits = 10, period = 2.minutes => 10 requests per 2 minutes to cdn.thumbnails.com

Since

extension-lib 14

Parameters

httpUrl

HttpUrl The url host that this interceptor should handle. Will get url's host by using HttpUrl.host()

permits

Int Number of requests allowed within a period of units.

period

Duration The limiting duration. Defaults to 1.seconds.


Deprecated

Default rate limiting implementation is no longer provided. Source developers are now responsible for implementing their own rate limiting logic if desired, to prevent forks from bypassing it.

Replace with

this

An OkHttp interceptor that handles given url host's rate limiting.

Examples:

url = "https://api.anime.com", permits = 5, period = 1.seconds => 5 requests per second to api.anime.com url = "https://cdn.thumbnails.com", permits = 10, period = 2.minutes => 10 requests per 2 minutes to cdn.thumbnails.com

Since

extension-lib 14

Parameters

url

String The url host that this interceptor should handle. Will get url's host by using HttpUrl.host()

permits

Int Number of requests allowed within a period of units.

period

Duration The limiting duration. Defaults to 1.seconds.