Skip to content

Commit

Permalink
Merge pull request #261 from nielsvanvelzen/timeout
Browse files Browse the repository at this point in the history
Add requestTimeout and socketTimeout to HttpClientOptions
  • Loading branch information
Maxr1998 authored May 21, 2021
2 parents b7ac057 + dab1fbc commit 47551ef
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
14 changes: 9 additions & 5 deletions jellyfin-api/api/jellyfin-api.api
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ public final class org/jellyfin/sdk/api/client/ApiClient$DefaultImpls {

public final class org/jellyfin/sdk/api/client/HttpClientOptions {
public fun <init> ()V
public fun <init> (ZJ)V
public synthetic fun <init> (ZJILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (ZJJJ)V
public synthetic fun <init> (ZJJJILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Z
public final fun component2 ()J
public final fun copy (ZJ)Lorg/jellyfin/sdk/api/client/HttpClientOptions;
public static synthetic fun copy$default (Lorg/jellyfin/sdk/api/client/HttpClientOptions;ZJILjava/lang/Object;)Lorg/jellyfin/sdk/api/client/HttpClientOptions;
public final fun component3 ()J
public final fun component4 ()J
public final fun copy (ZJJJ)Lorg/jellyfin/sdk/api/client/HttpClientOptions;
public static synthetic fun copy$default (Lorg/jellyfin/sdk/api/client/HttpClientOptions;ZJJJILjava/lang/Object;)Lorg/jellyfin/sdk/api/client/HttpClientOptions;
public fun equals (Ljava/lang/Object;)Z
public final fun getConnectTimeout ()J
public final fun getFollowRedirects ()Z
public final fun getTimeout ()J
public final fun getRequestTimeout ()J
public final fun getSocketTimeout ()J
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@ public data class HttpClientOptions(
val followRedirects: Boolean = true,

/**
* Timeout before a request failed. In milliseconds.
* Timeout for a complete HTTP request in milliseconds.
* Defaults to 30 seconds.
*/
val requestTimeout: Long = 30_000,

/**
* Timeout for connecting to the server in milliseconds.
* Defaults to 6 seconds.
*/
val timeout: Long = 6_000
val connectTimeout: Long = 6_000,

/**
* Timeout between receiving or writing messages in milliseconds.
* Defaults to 10 seconds.
*/
val socketTimeout: Long = 10_000,
)
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public open class KtorClient(
}

install(HttpTimeout) {
connectTimeoutMillis = httpClientOptions.timeout
connectTimeoutMillis = httpClientOptions.connectTimeout
requestTimeoutMillis = httpClientOptions.requestTimeout
socketTimeoutMillis = httpClientOptions.socketTimeout
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public class RecommendedServerDiscovery(
baseUrl = address,
httpClientOptions = HttpClientOptions(
followRedirects = false,
timeout = HTTP_TIMEOUT,
connectTimeout = HTTP_TIMEOUT,
requestTimeout = HTTP_TIMEOUT,
socketTimeout = HTTP_TIMEOUT,
),
)
val api = SystemApi(client)
Expand Down

0 comments on commit 47551ef

Please sign in to comment.