Skip to content

Commit

Permalink
fix detekt
Browse files Browse the repository at this point in the history
  • Loading branch information
osoykan committed Nov 28, 2024
1 parent adbe246 commit 9a7ce8d
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ fun <T> HttpStatement.readJsonTextStream(transform: suspend (line: String) -> T)
execute {
check(it.status.isSuccess()) { "Request failed with status: ${it.status}" }
while (!it.content.isClosedForRead) {
val line = it.content.readUTF8Line() ?: break
if (line.isBlank()) continue
emit(transform(line))
it.content.readUTF8Line()?.let { line ->
if (line.isBlank()) return@let
emit(transform(line))
}
}
}
}
Expand All @@ -26,9 +27,10 @@ fun <T> HttpStatement.readJsonContentStream(transform: suspend (line: ByteReadCh
execute {
check(it.status.isSuccess()) { "Request failed with status: ${it.status}" }
while (!it.content.isClosedForRead) {
val line = it.content.readUTF8Line() ?: break
if (line.isBlank()) continue
emit(transform(ByteReadChannel(line)))
it.content.readUTF8Line()?.let { line ->
if (line.isBlank()) return@let
emit(transform(ByteReadChannel(line.toByteArray())))
}
}
}
}
Expand Down

0 comments on commit 9a7ce8d

Please sign in to comment.