I'm experiencing something that I can't explain with Rails 2.3.2. I've created a new app, with one controller and one action to try narrowing this down. My entire controller is as follows.
class LinesController < ApplicationController
def show
respond_to do |format|
format.html { render :text => proc {|response, output|
10.times do |i|
output.write("This is line #{i}\n")
output.flush
end
}
}
end
end
end
When I run this under Rails 2.2.2 I see the following response.
$ curl http://localhost:3002/lines
This is line 0
This is line 1
This is line 2
This is line 3
This is line 4
This is line 5
This is line 6
This is line 7
This is line 8
This is line 9
However, when I run this under Rails 2.3.2, I get this instead.
$ curl http://localhost:3002/lines
curl: (18) transfer closed with outstanding read data remaining
If I hit this with a browser I see only the first line.
This is line 0
Note that my example code is directly out of the Rails documentation for render, except that I reduced the number of lines from 10 million to 10.
I suspect that the answer lies somewhere in the flush() method, but I'm currently stuck trying to dig an explanation out of the source code.