aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorRyan T. Hosford <tad.hosford@gmail.com>2016-03-03 00:43:18 -0600
committerRyan T. Hosford <tad.hosford@gmail.com>2016-03-13 19:51:49 -0500
commitb43158afba7fb4de6a3530d4f4e940f0c89bd057 (patch)
tree71291d8d0c30228e458fd39d126c4e4d2bd61191 /actionpack/lib/action_controller
parent7b96d860fd91e1802c5832cd97f54fda5368df2d (diff)
downloadrails-b43158afba7fb4de6a3530d4f4e940f0c89bd057.tar.gz
rails-b43158afba7fb4de6a3530d4f4e940f0c89bd057.tar.bz2
rails-b43158afba7fb4de6a3530d4f4e940f0c89bd057.zip
Fixes #23964
- Adds #each_chunk to ActionDispatch::Response. it's a method which will be called by ActionDispatch::Response#each. - Make Response#each a proper method instead of delegating to @stream - In Live, instead of overriding #each, override #each_chunk. - `#each` should just spit out @str_body if it's already set - Adds #test_set_header_after_read_body_during_action to prove this fixes #23964 - Adds #test_each_isnt_called_if_str_body_is_written to ensure #each_chunk is not called when @str_body is available - Call `@response.sent!` in AC::TestCase's #perform so a test response acts a bit more like a real response. Makes test that call `#assert_stream_closed` pass again. - Additionally assert `#committed?` in `#assert_stream_closed` - Make test that was calling @response.stream.each pass again by calling @response.each instead.
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/metal/live.rb16
-rw-r--r--actionpack/lib/action_controller/test_case.rb2
2 files changed, 10 insertions, 8 deletions
diff --git a/actionpack/lib/action_controller/metal/live.rb b/actionpack/lib/action_controller/metal/live.rb
index fc20e7a421..84a15d51a8 100644
--- a/actionpack/lib/action_controller/metal/live.rb
+++ b/actionpack/lib/action_controller/metal/live.rb
@@ -163,14 +163,6 @@ module ActionController
end
end
- def each
- @response.sending!
- while str = @buf.pop
- yield str
- end
- @response.sent!
- end
-
# Write a 'close' event to the buffer; the producer/writing thread
# uses this to notify us that it's finished supplying content.
#
@@ -210,6 +202,14 @@ module ActionController
def call_on_error
@error_callback.call
end
+
+ private
+
+ def each_chunk(&block)
+ while str = @buf.pop
+ yield str
+ end
+ end
end
class Response < ActionDispatch::Response #:nodoc: all
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index ecd21f29ce..ed2edcbe06 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -554,6 +554,8 @@ module ActionController
end
@request.query_string = ''
+ @response.sent!
+
@response
end