diff --git a/lib/stove-testing-e2e-http/src/main/kotlin/com/trendyol/stove/testing/e2e/http/streaming.kt b/lib/stove-testing-e2e-http/src/main/kotlin/com/trendyol/stove/testing/e2e/http/streaming.kt index f5ff0d8ab..aef0749f9 100644 --- a/lib/stove-testing-e2e-http/src/main/kotlin/com/trendyol/stove/testing/e2e/http/streaming.kt +++ b/lib/stove-testing-e2e-http/src/main/kotlin/com/trendyol/stove/testing/e2e/http/streaming.kt @@ -13,9 +13,10 @@ fun 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)) + } } } } @@ -26,9 +27,10 @@ fun 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()))) + } } } }