From a57860a9e9eab9a1925eb0f872ca3364f251c06b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 25 Dec 2022 12:23:50 +0000 Subject: extras/exec_cgi: fix for newer Rack::ContentLength 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(-) (limited to 'extras') 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 @@ class ExecCgi 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 @@ class ExecCgi 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 -- cgit v1.2.3-24-ge0c7