ssr86
02/21/2021, 12:20 AMdave
02/21/2021, 10:04 AMRazvan
02/21/2021, 11:39 AMRazvan
02/21/2021, 11:45 AMRazvan
02/21/2021, 4:27 PMRazvan
02/21/2021, 6:37 PMRazvan
02/21/2021, 8:57 PMKotlin SSE client
directly instead of Java… I would have found directly this implementation…
https://github.com/biowink/oksseRazvan
02/21/2021, 9:48 PMobject StreamSSE {
operator fun invoke(req: Request) {
val request = req
.replaceHeaders(
listOf(
"Accept-Encoding" to "",
"Accept" to "text/event-stream",
"Cache-Control" to "no-cache",
)
)
val noTimeoutClient = PreCannedOkHttpClients
.defaultOkHttpClient()
.newBuilder()
.readTimeout(Duration.ZERO)
.build()
OkHttp(client = noTimeoutClient, bodyMode = BodyMode.Stream).debug()(request).body.stream.bufferedReader().forEachLine {
println(it)
if (it.startsWith("End")) throw Exception("End")
}
}
}