Skip to content

Commit 766564f

Browse files
committed
Several fixes for AC::Streaming
1 parent 0258cc4 commit 766564f

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

actionpack/lib/action_controller/metal/streaming.rb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,17 @@ module ActionController # :nodoc:
99
# and then the layout. The response is sent to the client after the whole
1010
# template is rendered, all queries are made, and the layout is processed.
1111
#
12-
# Streaming inverts the rendering flow by rendering the layout first and
13-
# streaming each part of the layout as they are processed. This allows the
12+
# \Streaming inverts the rendering flow by rendering the layout first and
13+
# subsequently each part of the layout as they are processed. This allows the
1414
# header of the HTML (which is usually in the layout) to be streamed back
15-
# to client very quickly, allowing JavaScripts and stylesheets to be loaded
15+
# to client very quickly, enabling JavaScripts and stylesheets to be loaded
1616
# earlier than usual.
1717
#
18-
# This approach was introduced in Rails 3.1 and is still improving. Several
19-
# Rack middlewares may not work and you need to be careful when streaming.
20-
# Those points are going to be addressed soon.
18+
# Several Rack middlewares may not work and you need to be careful when streaming.
19+
# This is covered in more detail below, see the "Middlewares" section.
2120
#
22-
# In order to use streaming, you will need to use a Ruby version that
23-
# supports fibers (fibers are supported since version 1.9.2 of the main
24-
# Ruby implementation).
25-
#
26-
# Streaming can be added to a given template easily, all you need to do is
27-
# to pass the +:stream+ option.
21+
# \Streaming can be added to a given template easily, all you need to do is
22+
# to pass the +:stream+ option to +render+.
2823
#
2924
# class PostsController
3025
# def index
@@ -35,7 +30,7 @@ module ActionController # :nodoc:
3530
#
3631
# == When to use streaming
3732
#
38-
# Streaming may be considered to be overkill for lightweight actions like
33+
# \Streaming may be considered to be overkill for lightweight actions like
3934
# +new+ or +edit+. The real benefit of streaming is on expensive actions
4035
# that, for example, do a lot of queries on the database.
4136
#
@@ -59,7 +54,7 @@ module ActionController # :nodoc:
5954
# render stream: true
6055
# end
6156
#
62-
# Notice that +:stream+ only works with templates. Rendering +:json+
57+
# Notice that +:stream+ only works with templates. \Rendering +:json+
6358
# or +:xml+ with +:stream+ won't work.
6459
#
6560
# == Communication between layout and template
@@ -112,7 +107,7 @@ module ActionController # :nodoc:
112107
# This means that, if you have <code>yield :title</code> in your layout
113108
# and you want to use streaming, you would have to render the whole template
114109
# (and eventually trigger all queries) before streaming the title and all
115-
# assets, which kills the purpose of streaming. For this purpose, you can use
110+
# assets, which defeats the purpose of streaming. Alternatively, you can use
116111
# a helper called +provide+ that does the same as +content_for+ but tells the
117112
# layout to stop searching for other entries and continue rendering.
118113
#
@@ -122,7 +117,7 @@ module ActionController # :nodoc:
122117
# Hello
123118
# <%= content_for :title, " page" %>
124119
#
125-
# Giving:
120+
# Resulting in:
126121
#
127122
# <html>
128123
# <head><title>Main</title></head>
@@ -132,6 +127,8 @@ module ActionController # :nodoc:
132127
# That said, when streaming, you need to properly check your templates
133128
# and choose when to use +provide+ and +content_for+.
134129
#
130+
# See also ActionView::Helpers::CaptureHelper for more information.
131+
#
135132
# == Headers, cookies, session, and flash
136133
#
137134
# When streaming, the HTTP headers are sent to the client right before
@@ -161,9 +158,9 @@ module ActionController # :nodoc:
161158
#
162159
# "><script>window.location = "/500.html"</script></html>
163160
#
164-
# The first two characters (">) are required in case the exception happens
165-
# while rendering attributes for a given tag. You can check the real cause
166-
# for the exception in your logger.
161+
# The first two characters (<tt>"></tt>) are required in case the exception
162+
# happens while rendering attributes for a given tag. You can check the real
163+
# cause for the exception in your logger.
167164
#
168165
# == Web server support
169166
#
@@ -183,11 +180,13 @@ module ActionController # :nodoc:
183180
# unicorn_rails --config-file unicorn.config.rb
184181
#
185182
# You may also want to configure other parameters like <tt>:tcp_nodelay</tt>.
183+
#
186184
# Please check its documentation for more information:
187-
# https://bogomips.org/unicorn/Unicorn/Configurator.html#method-i-listen
185+
#
186+
# * https://bogomips.org/unicorn/Unicorn/Configurator.html#method-i-listen
188187
#
189188
# If you are using Unicorn with NGINX, you may need to tweak NGINX.
190-
# Streaming should work out of the box on Rainbows.
189+
# \Streaming should work out of the box on Rainbows.
191190
#
192191
# ==== Passenger
193192
#
@@ -203,7 +202,8 @@ module ActionController # :nodoc:
203202
# the response back to the client.
204203
#
205204
# Please check the documentation for more information:
206-
# https://www.phusionpassenger.com/docs/references/config_reference/nginx/#passenger_buffer_response
205+
#
206+
# * https://www.phusionpassenger.com/docs/references/config_reference/nginx/#passenger_buffer_response
207207
#
208208
module Streaming
209209
private

0 commit comments

Comments
 (0)