Skip to content
New issue

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

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

Already on GitHub? # to your account

Render directly to IO #507

Closed
paulcsmith opened this issue Jun 13, 2018 · 5 comments · Fixed by #1084
Closed

Render directly to IO #507

paulcsmith opened this issue Jun 13, 2018 · 5 comments · Fixed by #1084

Comments

@paulcsmith
Copy link
Member

https://stackoverflow.com/questions/50774451/how-to-free-memory-allocated-for-some-structure-in-crystal-manually/50782379#50782379

For both JSON and HTML pages.

Right now I don't think this is a big deal as performance is already excellent, but this should be done eventually

@jwoertink
Copy link
Member

I've been thinking about this, and trying to wrap my head around how this actually would work. I think the final output sent to the user is here. I think body at this point is either the HTML, or the JSON that's to be rendered to the user. If I understand this correctly, then context.response is an IO::Memory, and body what too at some point before this. So when we render directly to the IO, is it this context.response we would be writing to? If so, could we just set the view here to be context.response?

@paulcsmith
Copy link
Member Author

paulcsmith commented Mar 9, 2020 via email

@paulcsmith
Copy link
Member Author

Actually this might be bad...or need to be rethought. I'm not sure if as soon as you write to the response it starts streaming to the client. if so this would be a problem because it may encounter an error and have a half written HTML response and then raise a 500. I'm hoping that it doesn't just start streaming...but maybe it does.

@jwoertink
Copy link
Member

Yeah, probably would need lots of tests around that. I'm just not too familiar with the concept, so I was trying to think of what are these steps. Maybe I'll mess around with it a bit and test that later if I get some time.

@paulcsmith
Copy link
Member Author

paulcsmith commented Mar 9, 2020 via email

paulcsmith added a commit that referenced this issue Apr 4, 2020
Closes #507

This prints the io directly to the response, rather than making it a
string first. The bigger the response, the more helpful this will be.
paulcsmith added a commit that referenced this issue Apr 4, 2020
Closes #507

This prints the io directly to the response, rather than making it a
string first. The bigger the response, the more helpful this will be.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants