yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
* [PATCH 0/2] exec_cgi: fix compat with newer Rack 2
@ 2022-12-25 12:23 Eric Wong
  2022-12-25 12:23 ` [PATCH 1/2] extras/exec_cgi: fix for newer Rack::ContentLength Eric Wong
  2022-12-25 12:23 ` [PATCH 2/2] test/test_extras_exec_cgi: drop Rack::ContentLength Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2022-12-25 12:23 UTC (permalink / raw)
  To: yahns-public

Rack::ContentLength was causing problems with ExecCGI in the
extras/ problem.  Rack 3 is another can of worms I'll still
have to deal with :<

Eric Wong (2):
  extras/exec_cgi: fix for newer Rack::ContentLength
  test/test_extras_exec_cgi: drop Rack::ContentLength

 extras/exec_cgi.rb           | 7 ++++---
 test/test_extras_exec_cgi.rb | 3 ++-
 2 files changed, 6 insertions(+), 4 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] extras/exec_cgi: fix for newer Rack::ContentLength
  2022-12-25 12:23 [PATCH 0/2] exec_cgi: fix compat with newer Rack 2 Eric Wong
@ 2022-12-25 12:23 ` Eric Wong
  2022-12-25 12:23 ` [PATCH 2/2] test/test_extras_exec_cgi: drop Rack::ContentLength Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2022-12-25 12:23 UTC (permalink / raw)
  To: yahns-public

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
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] test/test_extras_exec_cgi: drop Rack::ContentLength
  2022-12-25 12:23 [PATCH 0/2] exec_cgi: fix compat with newer Rack 2 Eric Wong
  2022-12-25 12:23 ` [PATCH 1/2] extras/exec_cgi: fix for newer Rack::ContentLength Eric Wong
@ 2022-12-25 12:23 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2022-12-25 12:23 UTC (permalink / raw)
  To: yahns-public

It is causing _blocked_zombie to fail on rtype=11 due to the
addition of Content-Length making the client persistent when
we didn't actually want it to be (for the test).
---
 test/test_extras_exec_cgi.rb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test/test_extras_exec_cgi.rb b/test/test_extras_exec_cgi.rb
index 426409d..4fa928d 100644
--- a/test/test_extras_exec_cgi.rb
+++ b/test/test_extras_exec_cgi.rb
@@ -136,7 +136,7 @@ def _blocked_zombie(block_on, rtype)
       Yahns::HttpClient.__send__(:include, TrywriteBlocked)
       require './extras/exec_cgi'
       cfg.instance_eval do
-        stack = Rack::ContentLength.new(Rack::Chunked.new(ExecCgi.new(RUNME)))
+        stack = Rack::Chunked.new(ExecCgi.new(RUNME))
         app(:rack, stack) { listen "#{host}:#{port}" }
         stderr_path err.path
         worker_processes 1
@@ -170,6 +170,7 @@ def _blocked_zombie(block_on, rtype)
         assert_match %r{\A\d+\n\z}, body
         exec_pid = body.to_i
         poke_until_dead exec_pid
+        # lack of Content-Length should trigger EOF here:
         assert_raises(EOFError) { c.readpartial(666) }
       else
         raise "BUG in test, bad rtype"

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-25 12:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-25 12:23 [PATCH 0/2] exec_cgi: fix compat with newer Rack 2 Eric Wong
2022-12-25 12:23 ` [PATCH 1/2] extras/exec_cgi: fix for newer Rack::ContentLength Eric Wong
2022-12-25 12:23 ` [PATCH 2/2] test/test_extras_exec_cgi: drop Rack::ContentLength Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/yahns.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).