Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

close the response when the response body is set so that normal rende…

…r calls will work
  • Loading branch information...
commit fa3c4ea6d0dee5995d0ac56699540eb9a3149224 1 parent 4509494
@tenderlove tenderlove authored
View
5 actionpack/lib/action_controller/metal/live.rb
@@ -121,6 +121,11 @@ def process(name)
@_response.await_commit
end
+ def response_body=(body)
+ super
+ response.stream.close if response
+ end
+
def set_response!(request)
if request.env["HTTP_VERSION"] == "HTTP/1.0"
super
View
9 actionpack/test/controller/live_stream_test.rb
@@ -12,6 +12,10 @@ def self.controller_path
'test'
end
+ def render_text
+ render :text => 'zomg'
+ end
+
def default_header
response.stream.write "<html><body>hi</body></html>"
response.stream.close
@@ -107,5 +111,10 @@ def test_live_stream_default_header
_, headers, _ = @response.prepare!
assert headers['Content-Type']
end
+
+ def test_render_text
+ get :render_text
+ assert @response.stream.closed?, 'stream should be closed'
+ end
end
end

5 comments on commit fa3c4ea

@carlosantoniodasilva

Hey mate, this test is apparently failing randomly on travis, but it's passing locally for me =(, mind taking a look?

@rafaelfranca

I think is due a race condition. I could reproduce placing a sleep before response.stream.close if response

@tenderlove
Owner

Yes, I'll take a look! Thanks

@tenderlove
Owner

Should be fixed in c391919

Please sign in to comment.
Something went wrong with that request. Please try again.