about summary refs log tree commit homepage
path: root/extras
diff options
context:
space:
mode:
authorEric Wong <bofh@yhbt.net>2022-12-25 12:23:50 +0000
committerEric Wong <bofh@yhbt.net>2022-12-25 13:43:20 +0000
commita57860a9e9eab9a1925eb0f872ca3364f251c06b (patch)
tree69099aadc5dd7651d9f5137c698d744d9ae74481 /extras
parent84fc3880cecfabe7f3724dfb5f43b452916c5e1f (diff)
downloadyahns-a57860a9e9eab9a1925eb0f872ca3364f251c06b.tar.gz
Rack::ContentLength now unconditionally captures bodies and
doesn't dup the data yield by body#each.  Thus we can't reuse
buffers anymore.
Diffstat (limited to 'extras')
-rw-r--r--extras/exec_cgi.rb7
1 files 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 @@ 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