diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/yahns/proxy_http_response.rb | 9 | ||||
-rw-r--r-- | lib/yahns/wbuf_lite.rb | 7 |
2 files changed, 10 insertions, 6 deletions
diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb index 9867da2..316c310 100644 --- a/lib/yahns/proxy_http_response.rb +++ b/lib/yahns/proxy_http_response.rb @@ -10,13 +10,14 @@ require_relative 'wbuf_lite' module Yahns::HttpResponse # :nodoc: # switch and yield - def proxy_unbuffer(wbuf) + def proxy_unbuffer(wbuf, nxt = :ignore) @state = wbuf + wbuf.req_res = nil if nxt.nil? && wbuf.respond_to?(:req_res=) tc = Thread.current tc[:yahns_fdmap].remember(self) # Yahns::HttpClient tc[:yahns_queue].queue_mod(self, wbuf.busy == :wait_readable ? Yahns::Queue::QEV_RD : Yahns::Queue::QEV_WR) - :ignore + nxt end def wbuf_alloc(req_res) @@ -175,9 +176,9 @@ module Yahns::HttpResponse # :nodoc: # HTTP/1.0 upstream: wbuf = proxy_write(wbuf, "0\r\n\r\n".freeze, req_res) if alive - return proxy_unbuffer(wbuf) if Yahns::WbufLite === wbuf req_res.shutdown - break + return proxy_unbuffer(wbuf, nil) if Yahns::WbufLite === wbuf + return proxy_busy_mod(wbuf, req_res) when :wait_readable return wait_on_upstream(req_res) end until kcar.body_eof? diff --git a/lib/yahns/wbuf_lite.rb b/lib/yahns/wbuf_lite.rb index afee1e9..fa52f54 100644 --- a/lib/yahns/wbuf_lite.rb +++ b/lib/yahns/wbuf_lite.rb @@ -7,9 +7,11 @@ require_relative 'wbuf' # This is only used for "proxy_buffering: false" class Yahns::WbufLite < Yahns::Wbuf # :nodoc: attr_reader :busy + attr_writer :req_res def initialize(req_res) - super(nil, :ignore) + alive = req_res.alive + super(nil, alive ? :ignore : false) @req_res = req_res end @@ -35,8 +37,9 @@ class Yahns::WbufLite < Yahns::Wbuf # :nodoc: if @req_res client.hijack_cleanup Thread.current[:yahns_queue].queue_mod(@req_res, Yahns::Queue::QEV_RD) + return :ignore end - :ignore + @wbuf_persist rescue @req_res = @req_res.close if @req_res raise |