File tree Expand file tree Collapse file tree 3 files changed +15
-7
lines changed
Expand file tree Collapse file tree 3 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,10 @@ def initialize(path)
8585 @to_path = path
8686 end
8787
88+ def body
89+ File . binread ( to_path )
90+ end
91+
8892 # Stream the file's contents if Rack::Sendfile isn't present.
8993 def each
9094 File . open ( to_path , 'rb' ) do |file |
Original file line number Diff line number Diff line change @@ -136,10 +136,6 @@ class TestResponse < ActionDispatch::TestResponse
136136 end
137137
138138 class LiveTestResponse < Live ::Response
139- def body
140- @body ||= super
141- end
142-
143139 # Was the response successful?
144140 alias_method :success? , :successful?
145141
Original file line number Diff line number Diff line change @@ -80,11 +80,21 @@ def initialize(response, buf)
8080 @response = response
8181 @buf = buf
8282 @closed = false
83+ @str_body = nil
84+ end
85+
86+ def body
87+ @str_body ||= begin
88+ buf = ''
89+ each { |chunk | buf << chunk }
90+ buf
91+ end
8392 end
8493
8594 def write ( string )
8695 raise IOError , "closed stream" if closed?
8796
97+ @str_body = nil
8898 @response . commit!
8999 @buf . push string
90100 end
@@ -222,9 +232,7 @@ def message
222232 # Returns the content of the response as a string. This contains the contents
223233 # of any calls to <tt>render</tt>.
224234 def body
225- strings = [ ]
226- each { |part | strings << part . to_s }
227- strings . join
235+ @stream . body
228236 end
229237
230238 EMPTY = " "
You can’t perform that action at this time.
0 commit comments