We cannot rely on env being available after proxy_wait_next
---
Oops, fat-fingered sending the mail :x
Correct patch order should be:
req_res: store proxy_pass object here, instead
proxy_pass: redo "proxy_buffering: false"
wbuf: remove needless "busy" parameter
lib/yahns/proxy_http_response.rb | 4 ++--
lib/yahns/proxy_pass.rb | 3 +--
lib/yahns/req_res.rb | 4 +++-
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb
index 2968062..765fe14 100644
--- a/lib/yahns/proxy_http_response.rb
+++ b/lib/yahns/proxy_http_response.rb
@@ -27,7 +27,7 @@ def proxy_write(wbuf, buf, req_res)
when String, Array # partial write, hope the skb grows
buf = rv
when :wait_writable, :wait_readable
- if @hs.env['yahns.proxy_pass'].proxy_buffering
+ if req_res.proxy_pass.proxy_buffering
body = nil
alive = req_res.alive
else
@@ -88,7 +88,7 @@ def proxy_res_headers(res, req_res)
flags = MSG_DONTWAIT
alive = @hs.next? && self.class.persistent_connections
term = false
- response_headers = env['yahns.proxy_pass'].response_headers
+ response_headers = req_res.proxy_pass.response_headers
res = "HTTP/1.1 #{msg ? %Q(#{code} #{msg}) : status}\r\n".dup
headers.each do |key,value| # n.b.: headers is an Array of 2-element Arrays
diff --git a/lib/yahns/proxy_pass.rb b/lib/yahns/proxy_pass.rb
index ed37da5..fcd0cf7 100644
--- a/lib/yahns/proxy_pass.rb
+++ b/lib/yahns/proxy_pass.rb
@@ -89,10 +89,9 @@ def call(env)
ctype = env["CONTENT_TYPE"] and req << "Content-Type: #{ctype}\r\n"
clen = env["CONTENT_LENGTH"] and req << "Content-Length: #{clen}\r\n"
input = chunked || (clen && clen.to_i > 0) ? env['rack.input'] : nil
- env['yahns.proxy_pass'] = self
# finally, prepare to emit the headers
- rr.req_start(c, req << "\r\n".freeze, input, chunked)
+ rr.req_start(c, req << "\r\n".freeze, input, chunked, self)
# this probably breaks fewer middlewares than returning whatever else...
[ 500, [], [] ]
diff --git a/lib/yahns/req_res.rb b/lib/yahns/req_res.rb
index dd4ec87..f585bd9 100644
--- a/lib/yahns/req_res.rb
+++ b/lib/yahns/req_res.rb
@@ -11,12 +11,14 @@ class Yahns::ReqRes < Kgio::Socket # :nodoc:
attr_writer :paused
attr_accessor :proxy_trailers
attr_accessor :alive
+ attr_reader :proxy_pass
- def req_start(c, req, input, chunked)
+ def req_start(c, req, input, chunked, proxy_pass)
@hdr = @resbuf = nil
@yahns_client = c
@paused = false
@rrstate = input ? [ req, input, chunked ] : req
+ @proxy_pass = proxy_pass
Thread.current[:yahns_queue].queue_add(self, Yahns::Queue::QEV_WR)
end
--
unsubscribe: [email protected]
archive: https://yhbt.net/yahns-public/