Rack::ContentLength now unconditionally captures bodies and
doesn't dup the data yield by body#each. Thus we can't reuse
buffers anymore.
---
extras/exec_cgi.rb | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/extras/exec_cgi.rb b/extras/exec_cgi.rb
index 8a1939d..a04087d 100644
--- a/extras/exec_cgi.rb
+++ b/extras/exec_cgi.rb
@@ -34,14 +34,15 @@ def initialize(rd)
def each
buf = @body_tip
yield buf unless buf.empty?
+ buf = @body_tip = nil
- case tmp = @rd.read_nonblock(8192, buf, exception: false)
+ case tmp = @rd.read_nonblock(8192, exception: false)
when :wait_readable
@rd.wait_readable
when nil
break
else # String
- yield tmp
+ yield tmp.freeze
end while true
self
ensure
@@ -117,7 +118,7 @@ def call(env)
tmp.clear
end
head, body = head.split(/\r?\n\r?\n/, 2)
- io.body_tip = body
+ io.body_tip = body.freeze
env["HTTP_VERSION"] ||= "HTTP/1.0" # stop Rack::Chunked for HTTP/0.9