diff --git a/archive/src/main/kotlin/org/openrs2/archive/cache/nxt/MusicStreamClient.kt b/archive/src/main/kotlin/org/openrs2/archive/cache/nxt/MusicStreamClient.kt index 234d9fb0..f3300061 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/nxt/MusicStreamClient.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/nxt/MusicStreamClient.kt @@ -8,6 +8,7 @@ import org.openrs2.http.checkStatusCode import java.net.URI import java.net.http.HttpClient import java.net.http.HttpRequest +import java.time.Duration public class MusicStreamClient( private val client: HttpClient, @@ -19,6 +20,7 @@ public class MusicStreamClient( val request = HttpRequest.newBuilder(uri) .GET() + .timeout(Duration.ofSeconds(30)) .build() val response = client.sendAsync(request, byteBufBodyHandler).await() diff --git a/archive/src/main/kotlin/org/openrs2/archive/jav/JavConfig.kt b/archive/src/main/kotlin/org/openrs2/archive/jav/JavConfig.kt index 84786ac6..e4361827 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/jav/JavConfig.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/jav/JavConfig.kt @@ -9,6 +9,7 @@ import java.net.URI import java.net.http.HttpClient import java.net.http.HttpRequest import java.net.http.HttpResponse +import java.time.Duration public data class JavConfig( public val config: Map, @@ -19,6 +20,7 @@ public data class JavConfig( public suspend fun download(client: HttpClient, url: String): JavConfig { val request = HttpRequest.newBuilder(URI(url)) .GET() + .timeout(Duration.ofSeconds(30)) .build() val response = client.sendAsync(request, HttpResponse.BodyHandlers.ofInputStream()).await() diff --git a/archive/src/main/kotlin/org/openrs2/archive/key/JsonKeyDownloader.kt b/archive/src/main/kotlin/org/openrs2/archive/key/JsonKeyDownloader.kt index 4a8f9a86..a5f8839a 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/key/JsonKeyDownloader.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/key/JsonKeyDownloader.kt @@ -9,6 +9,7 @@ import java.net.URI import java.net.http.HttpClient import java.net.http.HttpRequest import java.net.http.HttpResponse +import java.time.Duration public abstract class JsonKeyDownloader( private val client: HttpClient, @@ -17,6 +18,7 @@ public abstract class JsonKeyDownloader( override suspend fun download(url: String): Sequence { val request = HttpRequest.newBuilder(URI(url)) .GET() + .timeout(Duration.ofSeconds(30)) .build() val response = client.sendAsync(request, HttpResponse.BodyHandlers.ofInputStream()).await() diff --git a/archive/src/main/kotlin/org/openrs2/archive/key/PolarKeyDownloader.kt b/archive/src/main/kotlin/org/openrs2/archive/key/PolarKeyDownloader.kt index dca63683..3c7aad48 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/key/PolarKeyDownloader.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/key/PolarKeyDownloader.kt @@ -10,6 +10,7 @@ import java.net.URI import java.net.http.HttpClient import java.net.http.HttpRequest import java.net.http.HttpResponse +import java.time.Duration import javax.inject.Inject import javax.inject.Singleton @@ -21,6 +22,7 @@ public class PolarKeyDownloader @Inject constructor( override suspend fun getMissingUrls(seenUrls: Set): Set { val request = HttpRequest.newBuilder(ENDPOINT) .GET() + .timeout(Duration.ofSeconds(30)) .build() val response = client.sendAsync(request, HttpResponse.BodyHandlers.ofInputStream()).await() diff --git a/archive/src/main/kotlin/org/openrs2/archive/key/RuneLiteKeyDownloader.kt b/archive/src/main/kotlin/org/openrs2/archive/key/RuneLiteKeyDownloader.kt index a8600863..471b6bc3 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/key/RuneLiteKeyDownloader.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/key/RuneLiteKeyDownloader.kt @@ -9,6 +9,7 @@ import java.net.URI import java.net.http.HttpClient import java.net.http.HttpRequest import java.net.http.HttpResponse +import java.time.Duration import javax.inject.Inject import javax.inject.Singleton @@ -25,6 +26,7 @@ public class RuneLiteKeyDownloader @Inject constructor( private suspend fun getVersion(): String { val request = HttpRequest.newBuilder(VERSION_ENDPOINT) .GET() + .timeout(Duration.ofSeconds(30)) .build() val response = client.sendAsync(request, HttpResponse.BodyHandlers.ofInputStream()).await() diff --git a/archive/src/main/kotlin/org/openrs2/archive/name/RuneStarNameDownloader.kt b/archive/src/main/kotlin/org/openrs2/archive/name/RuneStarNameDownloader.kt index a9a52196..23b4f36e 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/name/RuneStarNameDownloader.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/name/RuneStarNameDownloader.kt @@ -7,6 +7,7 @@ import java.net.URI import java.net.http.HttpClient import java.net.http.HttpRequest import java.net.http.HttpResponse +import java.time.Duration import javax.inject.Inject import javax.inject.Singleton import kotlin.streams.asSequence @@ -32,6 +33,7 @@ public class RuneStarNameDownloader @Inject constructor( private suspend fun readTsv(uri: URI, column: Int): Sequence { val request = HttpRequest.newBuilder(uri) .GET() + .timeout(Duration.ofSeconds(30)) .build() val response = client.sendAsync(request, HttpResponse.BodyHandlers.ofLines()).await() diff --git a/http/src/main/kotlin/org/openrs2/http/HttpClientProvider.kt b/http/src/main/kotlin/org/openrs2/http/HttpClientProvider.kt index 49b89599..cf879af4 100644 --- a/http/src/main/kotlin/org/openrs2/http/HttpClientProvider.kt +++ b/http/src/main/kotlin/org/openrs2/http/HttpClientProvider.kt @@ -3,12 +3,14 @@ package org.openrs2.http import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.asExecutor import java.net.http.HttpClient +import java.time.Duration import javax.inject.Provider public class HttpClientProvider : Provider { override fun get(): HttpClient { return HttpClient.newBuilder() .authenticator(NetrcAuthenticator.read()) + .connectTimeout(Duration.ofSeconds(30)) .executor(Dispatchers.IO.asExecutor()) .followRedirects(HttpClient.Redirect.NORMAL) .build()