Permalink
Browse files

use a sized buffer to prevent the queue being too large

  • Loading branch information...
1 parent 2da242f commit 37a764b8e0af585b3475a54566816a2ffc52401b @tenderlove tenderlove committed Aug 9, 2012
Showing with 10 additions and 10 deletions.
  1. +10 −10 actionpack/lib/action_controller/metal/live.rb
@@ -33,27 +33,27 @@ module ActionController
module Live
class Buffer < ActionDispatch::Response::Buffer #:nodoc:
def initialize(response)
- super(response, Queue.new)
+ super(response, SizedQueue.new(10))
end
def write(string)
unless @response.committed?
@response.headers["Cache-Control"] = "no-cache"
- @response.headers.delete("Content-Length")
+ @response.headers.delete "Content-Length"
end
super
end
def each
while str = @buf.pop
- yield(str)
+ yield str
end
end
def close
super
- @buf.push(nil)
+ @buf.push nil
end
end
@@ -78,7 +78,7 @@ def to_hash
end
def initialize(status = 200, header = {}, body = [])
- header = Header.new(self, header)
+ header = Header.new self, header
super(status, header, body)
end
@@ -89,11 +89,11 @@ def commit!
private
- def build_buffer(response, body)
- buf = Live::Buffer.new(response)
- body.each { |part| buf.write(part) }
- buf
- end
+ def build_buffer(response, body)
+ buf = Live::Buffer.new response
+ body.each { |part| buf.write part }
+ buf
+ end
end
def process(name)

0 comments on commit 37a764b

Please sign in to comment.