dave08
09/17/2018, 7:51 PMenleur
09/17/2018, 7:55 PMdave08
09/17/2018, 8:10 PMdave08
09/17/2018, 8:11 PMdave08
09/17/2018, 8:18 PMoctylFractal
09/17/2018, 8:25 PMJsonSerializer
[https://github.com/ktorio/ktor/blob/master/ktor-client/ktor-client-features/ktor-client-json/src/io/ktor/client/features/json/JsonSerializer.kt]
returns an OutgoingContent
You can implement WriteChannelContent
to be passed a `ByteWriteChannel`: https://github.com/ktorio/ktor/blob/master/ktor-http/src/io/ktor/http/content/OutgoingContent.kt#L86
You can then turn the ByteWriteChannel
into an OutputStream
https://github.com/Kotlin/kotlinx-io/blob/master/kotlinx-coroutines-io/kotlinx-coroutines-io-jvm/src/main/kotlin/kotlinx/coroutines/experimental/io/jvm/javaio/Blocking.kt#L22
Pass the OutputStream
to Gson, and it should be fully streaming.dave08
09/17/2018, 8:34 PMoctylFractal
09/17/2018, 8:34 PMoctylFractal
09/17/2018, 8:35 PMdave08
09/17/2018, 8:38 PMorangy
OutputStream
is still synchronous, so it will be blocking anywayoctylFractal
09/17/2018, 8:39 PMContentNegotiation
calls a function named transformDefaultContent
on the result: https://github.com/ktorio/ktor/blob/master/ktor-server/ktor-server-core/src/io/ktor/features/ContentNegotiation.kt#L85
that converts the result to an `OutgoingContent`: https://github.com/ktorio/ktor/blob/master/ktor-server/ktor-server-core/src/io/ktor/http/content/DefaultTransform.kt#L9
So it would be slightly more complex on the server side, since you wouldn't have the nice interface, but it would be easy to change https://github.com/ktorio/ktor/blob/master/ktor-features/ktor-jackson/src/io/ktor/jackson/JacksonConverter.kt
to return a new OutgoingContent that streams itoctylFractal
09/17/2018, 8:43 PMContent-length
-related optimizations.dave08
09/18/2018, 2:46 AMContent-Length
-related optimizations?octylFractal
09/18/2018, 2:54 AMContent-Length
, which probably doesn't make a huge difference either, but it can be useful to know how large an incoming payload is
streaming payloads also often switch to HTTP chunked mode, which is slightly more bytes over the wiredave08
09/18/2018, 2:56 AM