Skip to content
This repository
Browse code

render_for_text pushes a body part instead of replacing the whole body

  • Loading branch information...
commit a22a778f860032b9d6bf3a8b19d0b22fc174550c 1 parent 1414e2a
Jeremy Kemper jeremy authored
21 actionpack/lib/action_controller/base/responder.rb
@@ -5,18 +5,19 @@ def self.included(klass)
5 5 end
6 6
7 7 private
8   - def render_for_text(text = nil, append_response = false) #:nodoc:
  8 + def render_for_text(text) #:nodoc:
9 9 @performed_render = true
10 10
11   - if append_response
12   - response.body ||= ''
13   - response.body << text.to_s
14   - else
15   - response.body = case text
16   - when Proc then text
17   - when nil then " " # Safari doesn't pass the headers of the return if the response is zero length
18   - else text.to_s
  11 + case text
  12 + when Proc
  13 + response.body = text
  14 + when nil
  15 + # Safari 2 doesn't pass response headers if the response is zero-length
  16 + if response.body_parts.empty?
  17 + response.body_parts << ' '
19 18 end
  19 + else
  20 + response.body_parts << text
20 21 end
21 22 end
22 23
@@ -39,4 +40,4 @@ def action_methods
39 40 end
40 41 end
41 42 end
42   -end
  43 +end
1  actionpack/lib/action_controller/testing/process.rb
@@ -287,6 +287,7 @@ class TestResponse < ActionDispatch::Response
287 287 include TestResponseBehavior
288 288
289 289 def recycle!
  290 + body_parts.clear
290 291 headers.delete('ETag')
291 292 headers.delete('Last-Modified')
292 293 end

0 comments on commit a22a778

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