Skip to content

Commit

Permalink
chore: revert to okhttp
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexcited committed Oct 12, 2024
1 parent 5f13778 commit c260d32
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ kotlinx-datetime = "0.6.1"
[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref= "ktor" }
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" }
Expand Down
6 changes: 3 additions & 3 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ kotlin {
val commonMain by getting {
dependencies {
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.cio)
implementation(libs.ktor.client.okhttp)

implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.serialization.core)
Expand All @@ -40,13 +40,13 @@ kotlin {
}
val jvmMain by getting {
dependencies {
implementation(libs.ktor.client.cio)
implementation(libs.ktor.client.okhttp)
implementation(libs.kotlin.test)
}
}
val androidMain by getting {
dependencies {
implementation(libs.ktor.client.cio)
implementation(libs.ktor.client.okhttp)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import ink.literate.pawnote.decoders.decodeGeolocatedInstance
import ink.literate.pawnote.models.GeolocatedInstance
import ink.literate.pawnote.models.Position
import io.ktor.client.*
import io.ktor.client.engine.cio.CIO
import io.ktor.client.request.forms.*
import io.ktor.client.statement.*
import io.ktor.http.*
Expand All @@ -14,7 +13,7 @@ import kotlinx.serialization.json.jsonObject

suspend fun geolocation(
position: Position,
httpClient: HttpClient = HttpClient(CIO)
httpClient: HttpClient = HttpClient()
): List<GeolocatedInstance> {
val res =
httpClient.submitForm(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import ink.literate.pawnote.api.helpers.clearURL
import ink.literate.pawnote.decoders.decodeInstance
import ink.literate.pawnote.models.Instance
import io.ktor.client.*
import io.ktor.client.engine.cio.CIO
import io.ktor.client.request.*
import io.ktor.client.statement.*
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.jsonObject

suspend fun instance(url: String, httpClient: HttpClient = HttpClient(CIO)): Instance {
suspend fun instance(url: String, httpClient: HttpClient = HttpClient()): Instance {
var cleanedURL = clearURL(url)
cleanedURL += "/infoMobileApp.json?id=0D264427-EEFC-4810-A9E9-346942A862A4"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import ink.literate.pawnote.models.errors.BusyPageError
import ink.literate.pawnote.models.errors.PageUnavailableError
import ink.literate.pawnote.models.errors.SuspendedIPError
import io.ktor.client.*
import io.ktor.client.engine.cio.CIO
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
Expand All @@ -24,7 +23,7 @@ data class SessionInfoParams(

suspend fun sessionInformation(
options: SessionInfoParams,
httpClient: HttpClient = HttpClient (CIO) { followRedirects = false }
httpClient: HttpClient = HttpClient { followRedirects = false }
): SessionInformation {
val url = Url(options.base + "/" + encodeAccountKindToPath(options.kind))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ink.literate.pawnote.models

import io.ktor.client.*
import io.ktor.client.engine.cio.CIO

/** Equivalent of a PRONOTE session. Contains metadata, AES keys, RSA modulus, and more. */
data class SessionHandle(
Expand All @@ -10,5 +9,5 @@ data class SessionHandle(
var instance: InstanceParameters,
var user: UserParameters,
var userResource: UserResource,
val client: HttpClient = HttpClient(CIO)
val client: HttpClient = HttpClient()
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ink.literate.pawnote.api.private.Keys
import ink.literate.pawnote.api.private.aesKeys
import ink.literate.pawnote.models.SessionInformation
import io.ktor.client.*
import io.ktor.client.engine.cio.CIO
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
Expand Down Expand Up @@ -81,7 +80,7 @@ actual constructor(
}

val response =
HttpClient(CIO).request(payload.url) {
HttpClient().request(payload.url) {
method = HttpMethod.Post
header("Content-Type", "application/json")
setBody(Json.encodeToString(requestData))
Expand Down

0 comments on commit c260d32

Please sign in to comment.