diff --git a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/KtorMeetacyEngine.kt b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/KtorMeetacyEngine.kt index d3381dd4..ba6b9032 100644 --- a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/KtorMeetacyEngine.kt +++ b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/KtorMeetacyEngine.kt @@ -50,10 +50,7 @@ public class KtorMeetacyEngine( json(json) } defaultRequest { - println("ca62: ${url.protocol}: isWebsocket = ${url.protocol.isWebsocket()}") - if (!url.protocol.isWebsocket()) { - header(HttpHeaders.ContentType, ContentType.Application.Json) - } + header(HttpHeaders.ContentType, ContentType.Application.Json) } } diff --git a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/RSocket.kt b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/RSocket.kt index 11f6cf5d..b18e8bde 100644 --- a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/RSocket.kt +++ b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/RSocket.kt @@ -5,8 +5,12 @@ import app.meetacy.sdk.engine.ktor.response.ServerResponse import app.meetacy.sdk.exception.MeetacyConnectionException import app.meetacy.sdk.exception.MeetacyInternalException import app.meetacy.sdk.exception.meetacyApiError +import io.ktor.client.* +import io.ktor.http.* import io.ktor.utils.io.errors.* +import io.rsocket.kotlin.RSocket import io.rsocket.kotlin.RSocketError +import io.rsocket.kotlin.ktor.client.rSocket import kotlinx.coroutines.CancellationException import kotlinx.serialization.json.Json @@ -37,3 +41,15 @@ internal inline fun handleRSocketExceptions( } } } + +internal suspend fun HttpClient.meetacyRSocket( + urlString: String, + secure: Boolean +): RSocket { + return rSocket( + urlString = urlString, + secure = secure + ) { + headers.remove(HttpHeaders.ContentType) + } +} diff --git a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/friends/FriendsEngine.kt b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/friends/FriendsEngine.kt index 9f26a82d..29b4e9bb 100644 --- a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/friends/FriendsEngine.kt +++ b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/friends/FriendsEngine.kt @@ -4,6 +4,7 @@ package app.meetacy.sdk.engine.ktor.requests.friends import app.meetacy.sdk.engine.ktor.apiVersion import app.meetacy.sdk.engine.ktor.handleRSocketExceptions +import app.meetacy.sdk.engine.ktor.meetacyRSocket import app.meetacy.sdk.engine.ktor.response.ListFriendsResponse import app.meetacy.sdk.engine.ktor.response.StatusTrueResponse import app.meetacy.sdk.engine.ktor.response.bodyAsSuccess @@ -109,7 +110,7 @@ internal class FriendsEngine( suspend fun streamFriendsLocation(request: EmitFriendsLocationRequest) = handleRSocketExceptions(json) { val url = baseUrl.replaceProtocolWithWebsocket() / "location" / "stream" - val socket = httpClient.rSocket( + val socket = httpClient.meetacyRSocket( urlString = url.string, secure = url.protocol.isWss ) diff --git a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/updates/UpdatesEngine.kt b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/updates/UpdatesEngine.kt index aa2df3b7..0d020c80 100644 --- a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/updates/UpdatesEngine.kt +++ b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/updates/UpdatesEngine.kt @@ -1,6 +1,7 @@ package app.meetacy.sdk.engine.ktor.requests.updates import app.meetacy.sdk.engine.ktor.handleRSocketExceptions +import app.meetacy.sdk.engine.ktor.meetacyRSocket import app.meetacy.sdk.engine.requests.EmitUpdatesRequest import app.meetacy.sdk.types.serializable.notification.NotificationSerializable import app.meetacy.sdk.types.serializable.notification.type @@ -29,7 +30,7 @@ internal class UpdatesEngine( suspend fun stream(request: EmitUpdatesRequest) = handleRSocketExceptions(json) { val url = baseUrl.replaceProtocolWithWebsocket() / "updates" / "stream" - val socket = httpClient.rSocket( + val socket = httpClient.meetacyRSocket( urlString = url.string, secure = url.protocol.isWss )