Merge pull request #48 from ouchadam/dependabot/gradle/ktorVer-2.0.2

Bump ktorVer from 2.0.1 to 2.0.2
This commit is contained in:
Adam Brown 2022-06-11 11:12:12 +01:00 committed by GitHub
commit f80c829010
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 12 deletions

View File

@ -91,7 +91,7 @@ ext.Dependencies.with {
def kotlinVer = "1.6.10"
def sqldelightVer = "1.5.3"
def composeVer = "1.1.0"
def ktorVer = "2.0.1"
def ktorVer = "2.0.2"
google = new DependenciesContainer()
google.with {
@ -123,8 +123,10 @@ ext.Dependencies.with {
ktorAndroid = "io.ktor:ktor-client-android:${ktorVer}"
ktorCore = "io.ktor:ktor-client-core:${ktorVer}"
ktorSerialization = "io.ktor:ktor-client-serialization:${ktorVer}"
ktorJson = "io.ktor:ktor-serialization-kotlinx-json:${ktorVer}"
ktorLogging = "io.ktor:ktor-client-logging-jvm:${ktorVer}"
ktorJava = "io.ktor:ktor-client-java:${ktorVer}"
ktorContentNegotiation = "io.ktor:ktor-client-content-negotiation:${ktorVer}"
coil = "io.coil-kt:coil-compose:2.1.0"
accompanistSystemuicontroller = "com.google.accompanist:accompanist-systemuicontroller:0.24.9-beta"

View File

@ -9,5 +9,6 @@ dependencies {
implementation Dependencies.mavenCentral.ktorCore
implementation Dependencies.mavenCentral.ktorSerialization
implementation Dependencies.mavenCentral.ktorLogging
implementation Dependencies.mavenCentral.kotlinSerializationJson
implementation Dependencies.mavenCentral.ktorContentNegotiation
implementation Dependencies.mavenCentral.ktorJson
}

View File

@ -4,9 +4,9 @@ import app.dapk.st.matrix.common.CredentialsStore
import app.dapk.st.matrix.http.MatrixHttpClient
import app.dapk.st.matrix.http.ktor.internal.KtorMatrixHttpClient
import io.ktor.client.*
import io.ktor.client.plugins.json.*
import io.ktor.client.plugins.kotlinx.serializer.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.client.plugins.logging.*
import io.ktor.serialization.kotlinx.json.*
import kotlinx.serialization.json.Json
class KtorMatrixHttpClientFactory(
@ -14,10 +14,10 @@ class KtorMatrixHttpClientFactory(
private val includeLogging: Boolean,
) : MatrixHttpClient.Factory {
override fun create(json: Json): MatrixHttpClient {
override fun create(jsonInstance: Json): MatrixHttpClient {
val client = HttpClient {
install(JsonPlugin) {
serializer = KotlinxSerializer(json)
install(ContentNegotiation) {
json(jsonInstance)
}
expectSuccess = true
if (includeLogging) {

View File

@ -42,16 +42,16 @@ internal fun registerRequest(userName: String, password: String, baseUrl: String
baseUrl = baseUrl,
)
internal fun wellKnownRequest(baseUrl: String) = httpRequest<String>(
internal fun wellKnownRequest(baseUrl: String) = httpRequest<RawResponse>(
path = ".well-known/matrix/client",
method = MatrixHttpClient.Method.GET,
baseUrl = baseUrl,
authenticated = false,
)
@JvmInline
@Serializable
internal value class RawResponse(val value: String)
typealias RawResponse = ByteArray
fun RawResponse.readString() = this.toString(Charsets.UTF_8)
internal data class Auth(
val session: String,

View File

@ -6,6 +6,7 @@ import io.ktor.http.*
import kotlinx.serialization.SerializationException
import kotlinx.serialization.json.Json
import java.net.UnknownHostException
import java.nio.charset.Charset
internal typealias FetchWellKnownUseCase = suspend (String) -> WellKnownResult
@ -17,7 +18,7 @@ internal class FetchWellKnownUseCaseImpl(
override suspend fun invoke(domainUrl: String): WellKnownResult {
return runCatching {
val rawResponse = httpClient.execute(rawWellKnownRequestForServersWithoutContentTypes(domainUrl))
json.decodeFromString(ApiWellKnown.serializer(), rawResponse)
json.decodeFromString(ApiWellKnown.serializer(), rawResponse.readString())
}
.fold(
onSuccess = { WellKnownResult.Success(it) },