Right now, if notModified(etag = true) middleware is applied and the body is a ResponseBody.Writer, kog realizes the lazy writer into a bytearray to generate an etag.
For instance, a lot of templating libraries have an api template.evaluate(java.io.writer, mapOf("foo" to 42)) where you pass in a writer that it writes to, so I created a new sealed member ResponseBody.Writer((java.io.Writer) -> Unit) so that users could provide a lazy writer that will write at some point in the future.
But the naive strategy of realizing the lazy writer only works on small bodies. Imagine if the user used ResponseBody.Writer to write massive responses. kog wouldn't want to realize the entire body in memory before sending it.
Right now, if
notModified(etag = true)
middleware is applied and the body is aResponseBody.Writer
, kog realizes the lazy writer into a bytearray to generate an etag.For instance, a lot of templating libraries have an api
template.evaluate(java.io.writer, mapOf("foo" to 42))
where you pass in a writer that it writes to, so I created a new sealed memberResponseBody.Writer((java.io.Writer) -> Unit)
so that users could provide a lazy writer that will write at some point in the future.But the naive strategy of realizing the lazy writer only works on small bodies. Imagine if the user used ResponseBody.Writer to write massive responses. kog wouldn't want to realize the entire body in memory before sending it.