Skip to content

Commit

Permalink
[1.204.*] Pre-release merge (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
tramline-github[bot] authored Jul 28, 2024
2 parents 62a5cf8 + 93542aa commit c62323f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions core/network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ kotlin {
implementation(libs.ktxml)
implementation(libs.kermit)
implementation(libs.crashkios.bugsnag)
api(libs.korlibs.string)
}
commonTest.dependencies { implementation(libs.kotlin.test) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import io.ktor.http.HttpStatusCode
import io.ktor.http.URLBuilder
import io.ktor.http.URLProtocol
import io.ktor.http.Url
import io.ktor.http.charset
import io.ktor.http.contentType
import io.ktor.utils.io.charsets.Charsets
import korlibs.io.lang.Charset
import korlibs.io.lang.Charsets
import me.tatarka.inject.annotations.Inject

@Inject
Expand Down Expand Up @@ -99,12 +99,10 @@ class FeedFetcher(private val httpClient: HttpClient, private val feedParser: Fe
}
} else {
val content = response.bodyAsChannel()
val feedPayload =
feedParser.parse(
feedUrl = url,
content = content,
charset = response.charset() ?: Charsets.UTF_8
)
val responseCharset = response.contentType()?.parameter("charset")
val charset = Charset.forName(responseCharset ?: Charsets.UTF8.name)

val feedPayload = feedParser.parse(feedUrl = url, content = content, charset = charset)

FeedFetchResult.Success(feedPayload)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ import io.ktor.http.URLBuilder
import io.ktor.http.URLProtocol
import io.ktor.http.set
import io.ktor.utils.io.ByteReadChannel
import io.ktor.utils.io.charsets.Charset
import io.ktor.utils.io.charsets.decode
import io.ktor.utils.io.core.String
import io.ktor.utils.io.core.readBytes
import korlibs.io.lang.Charset
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -156,7 +157,8 @@ private fun ByteReadChannel.toCharIterator(
if (this@toCharIterator.isClosedForRead) return false

val packet = runBlocking(context) { this@toCharIterator.readRemaining(DEFAULT_BUFFER_SIZE) }
currentBuffer = String(bytes = packet.readBytes(), charset = charset)
currentBuffer = buildString { charset.decode(this, packet.readBytes()) }

packet.release()
currentIndex = 0
return currentBuffer.isNotEmpty()
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ bugsnag = "6.6.1"
crashkios-bugsnag = "0.8.6"
kermit = "2.0.4"
reorderable = "2.2.0"
korlibs = "6.0.0"

[libraries]
compose_runtime = { module = "org.jetbrains.compose.runtime:runtime", version.ref = "compose" }
Expand Down Expand Up @@ -120,6 +121,7 @@ crashkios-bugsnag = { module = "co.touchlab.crashkios:bugsnag", version.ref = "c
kermit = { module = "co.touchlab:kermit", version.ref = "kermit" }
kermit-bugsnag = { module = "co.touchlab:kermit-bugsnag", version.ref = "kermit" }
reorderable = { module = "sh.calvin.reorderable:reorderable", version.ref = "reorderable" }
korlibs-string = { module = "com.soywiz:korlibs-string", version.ref = "korlibs" }

[plugins]
android_application = { id = "com.android.application", version.ref = "android_gradle_plugin" }
Expand Down

0 comments on commit c62323f

Please sign in to comment.