I have a need to stream a large amount of data from a Merb
application, so I tried using a defer_to block in the router, and
return a Rack response:
match("/stream").defer_to do |request, params|
[200, {'Content-Type' => 'whatever', 'Content-Length' => '9999999'},
object_with_an_each_method]
end
As I imply in the code snippet, I can calculate the content type and
content length in advance, but I want to generate that data piece by
piece in my object's each method. This works fine, but the
Merb::Rack::Handler::Mongrel class doesn't write out what it is given
when it is given it, it does:
body.each { |part|
response.body << part
}
response.finished # This actually sends the status, headers, and body
If the response is gigantic, this will cause huge memory bloat, right?
What I'm wondering is why it was written this way, and not something
like:
response.send_status(nil)
response.send_header
body.each { |part|
response.write(part)
}
Thanks for any insight you can offer.
matt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---