#55 ✓resolved
rack (at dima.spb)

Usage of sessionns prevents streaming - response is fully read before sending to client

Reported by rack (at dima.spb) | June 20th, 2009 @ 12:22 AM | in 1.1

[ Hello... got a bit confused where rack issues should be filed and tried to fill at http://github.com/chneukirchen/rack/issues#issue/3 Retrying here.]

Previously it was possible to implement scripts which slowly "stream" some HTML/JS code to the client browser by returning from page handler an object implementing 'each' method. It worked fine with 0.9.2. However with 1.0.0, the Rack::Session::Abstract::ID implementation does in fact buffering of the whole response before returning it to the client. Because of that it is no longer possible to create a long-running request handler which slowly sends events (by the means of JS code) to the client.

I believe this happens because of redundant use of Rack::Response object which is constructed in the commit_session method. just to call its set_cookie method (because the actual response object is not available at that place). However, the Rack::Response initialize method executes body's.each which blocks output until the each finishes (which never occurs when streaming).

To avoid this problem i patched the ID implementation to use temporary Rack::Response only as a container for cookies without letting it to do anything with body.

I guess this fix is probably not perfect - I'm providing it for reference only. Would be happy to accept a better fix if you have any.
Thanks.

Note that my patch only patches Session::Abstract::ID but Session::Cookie must be patched exactly the same way.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Attachments

Pages