Skip to content

Commit

Permalink
Bump ktorVersion from 1.6.8 to 2.0.0 (#118)
Browse files Browse the repository at this point in the history
* Bump ktorVersion from 1.6.8 to 2.0.0

Bumps `ktorVersion` from 1.6.8 to 2.0.0.

Updates `ktor-client-core` from 1.6.8 to 2.0.0
- [Release notes](https://github.com/ktorio/ktor/releases)
- [Changelog](https://github.com/ktorio/ktor/blob/main/CHANGELOG.md)
- [Commits](ktorio/ktor@1.6.8...2.0.0)

Updates `ktor-client-cio` from 1.6.8 to 2.0.0
- [Release notes](https://github.com/ktorio/ktor/releases)
- [Changelog](https://github.com/ktorio/ktor/blob/main/CHANGELOG.md)
- [Commits](ktorio/ktor@1.6.8...2.0.0)

---
updated-dependencies:
- dependency-name: io.ktor:ktor-client-core
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: io.ktor:ktor-client-cio
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Migrate to Ktor 2.0

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: hfhbd <hfhbd@users.noreply.github.com>
  • Loading branch information
dependabot[bot] and hfhbd authored Apr 11, 2022
1 parent 3caa8e7 commit 3eaec85
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cloudkitclient-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kotlin {

sourceSets {
// Apache 2, https://github.com/ktorio/ktor/releases/latest
val ktorVersion = "1.6.8"
val ktorVersion = "2.0.0"
commonMain {
dependencies {
api("io.ktor:ktor-client-core:$ktorVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import app.softwork.cloudkitclient.Record.*
import app.softwork.cloudkitclient.internal.*
import app.softwork.cloudkitclient.types.*
import app.softwork.cloudkitclient.values.*
import io.ktor.client.call.*
import io.ktor.client.features.*
import io.ktor.client.plugins.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
Expand Down Expand Up @@ -44,7 +43,8 @@ public class CKClient(
public override val privateDB: Database = Database("private")
public override val sharedDB: Database = Database("shared")

override suspend fun download(assetToDownload: Asset): ByteArray = httpClient { }.get(assetToDownload.downloadURL!!)
override suspend fun download(assetToDownload: Asset): ByteArray =
httpClient { }.get(assetToDownload.downloadURL!!).readBytes()

public inner class Database internal constructor(internal val name: String) : Client.Database {
public override suspend fun <F : Fields, R : Record<F>> query(
Expand Down Expand Up @@ -144,17 +144,17 @@ public class CKClient(
), zoneID = zoneID
)
}.let {
json.decodeFromString(Asset.Upload.Response.serializer(), it.receive())
json.decodeFromString(Asset.Upload.Response.serializer(), it.bodyAsText())
}.tokens.first().let {
httpClient { }.post<String>(it.url) { body = asset }
httpClient { }.post(it.url) { setBody(asset) }.bodyAsText()
}.let {
json.decodeFromString(Asset.Upload.Response.SingleFile.serializer(), it)
}.singleFile

override suspend fun createToken(): Push.Response = request("/tokens/create", Push.Create.serializer()) {
Push.Create(environment)
}.let {
json.decodeFromString(Push.Response.serializer(), it.receive())
json.decodeFromString(Push.Response.serializer(), it.bodyAsText())
}
}

Expand All @@ -176,14 +176,14 @@ public class CKClient(
url.takeFrom(subPath)
header("X-Apple-CloudKit-Request-ISO8601Date", date)
header("X-Apple-CloudKit-Request-SignatureV1", signature)
this.body = body
setBody(body)
}


private suspend fun <F : Fields, R : Record<F>> HttpResponse.toResponse(
recordInformation: Information<F, R>
): List<R> {
val body = receive<String>()
val body = bodyAsText()
logging("response ($status): $body")
try {
return json.decodeFromString(
Expand Down

0 comments on commit 3eaec85

Please sign in to comment.