Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decide what to do when user provides a ResponseBody.Writer but wants to generate an etag #7

Open
danneu opened this issue Jan 29, 2017 · 1 comment

Comments

@danneu
Copy link
Owner

danneu commented Jan 29, 2017

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.

@danneu danneu changed the title Decide what to do when use provides ResponseBody.Writer but wants to generate an etag Decide what to do when user provides a ResponseBody.Writer but wants to generate an etag Jan 29, 2017
@danneu
Copy link
Owner Author

danneu commented Jan 29, 2017

I should probably treat it like ResponseBody.InputStream and leave etag == null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant