aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-07-06 20:24:15 -0300
committerJosé Valim <jose.valim@gmail.com>2011-07-06 20:24:30 -0300
commit7da88c5b297486cd90696133d287be7d60d65218 (patch)
tree8d813b7ef702de6838d6a547b7e72d5a0fe0c6d5 /actionpack
parent689c3d674c34c0be6ec8dbadbb573b5b4abb6029 (diff)
downloadrails-7da88c5b297486cd90696133d287be7d60d65218.tar.gz
rails-7da88c5b297486cd90696133d287be7d60d65218.tar.bz2
rails-7da88c5b297486cd90696133d287be7d60d65218.zip
Remove stream at the class level.
This is because only template rendering works with streaming. Setting it at the class level was also changing the behavior of JSON and XML responses, closes #1337.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/metal/streaming.rb43
-rw-r--r--actionpack/test/controller/new_base/render_streaming_test.rb2
2 files changed, 6 insertions, 39 deletions
diff --git a/actionpack/lib/action_controller/metal/streaming.rb b/actionpack/lib/action_controller/metal/streaming.rb
index 0bb436a476..5fe5334458 100644
--- a/actionpack/lib/action_controller/metal/streaming.rb
+++ b/actionpack/lib/action_controller/metal/streaming.rb
@@ -24,20 +24,8 @@ module ActionController #:nodoc:
#
# == Examples
#
- # Streaming can be added to a controller easily, all you need to do is
- # call +stream+ in the controller class:
- #
- # class PostsController
- # stream
- # end
- #
- # The +stream+ method accepts the same options as +before_filter+ and friends:
- #
- # class PostsController
- # stream :only => :index
- # end
- #
- # You can also selectively turn on streaming for specific actions:
+ # Streaming can be added to a given template easily, all you need to do is
+ # to pass the :stream option.
#
# class PostsController
# def index
@@ -72,6 +60,9 @@ module ActionController #:nodoc:
# render :stream => true
# end
#
+ # Notice that :stream only works with templates. Rendering :json
+ # or :xml with :stream won't work.
+ #
# == Communication between layout and template
#
# When streaming, rendering happens top-down instead of inside-out.
@@ -209,33 +200,9 @@ module ActionController #:nodoc:
extend ActiveSupport::Concern
include AbstractController::Rendering
- attr_internal :stream
-
- module ClassMethods
- # Render streaming templates. It accepts :only, :except, :if and :unless as options
- # to specify when to stream, as in ActionController filters.
- def stream(options={})
- if defined?(Fiber)
- before_filter :_stream_filter, options
- else
- raise "You cannot use streaming if Fiber is not available."
- end
- end
- end
protected
- # Mark following render calls as streaming.
- def _stream_filter #:nodoc:
- self.stream = true
- end
-
- # Consider the stream option when normalazing options.
- def _normalize_options(options) #:nodoc:
- super
- options[:stream] = self.stream unless options.key?(:stream)
- end
-
# Set proper cache control and transfer encoding when streaming
def _process_options(options) #:nodoc:
super
diff --git a/actionpack/test/controller/new_base/render_streaming_test.rb b/actionpack/test/controller/new_base/render_streaming_test.rb
index 48cf0ab9cb..1a17e24914 100644
--- a/actionpack/test/controller/new_base/render_streaming_test.rb
+++ b/actionpack/test/controller/new_base/render_streaming_test.rb
@@ -10,9 +10,9 @@ module RenderStreaming
)]
layout "application"
- stream :only => [:hello_world, :skip]
def hello_world
+ render :stream => true
end
def layout_exception