about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-05-03 23:10:31 +0000
committerEric Wong <e@80x24.org>2016-05-16 01:13:01 +0000
commite6c9c4760c735339b2eac0783d1bd9c40a94d2a5 (patch)
tree04ac077ad1be7df686f9bbfbe692dd9539a794bf /lib
parentff5201fb34b6ceb83cf0f795ab9639d5c0089695 (diff)
downloadyahns-e6c9c4760c735339b2eac0783d1bd9c40a94d2a5.tar.gz
proxy_response_start is gigantic an hard-to-read, we can
more clearly see the lifetimes of some objects, now, and
hopefully shorten some of them.
Diffstat (limited to 'lib')
-rw-r--r--lib/yahns/proxy_http_response.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb
index bd274fe..693528f 100644
--- a/lib/yahns/proxy_http_response.rb
+++ b/lib/yahns/proxy_http_response.rb
@@ -61,11 +61,7 @@ module Yahns::HttpResponse # :nodoc:
     :wait_readable # self remains in :ignore, wait on upstream
   end
 
-  # start streaming the response once upstream is done sending headers to us.
-  # returns :wait_readable if we need to read more from req_res
-  # returns :ignore if we yield control to the client(self)
-  # returns nil if completely done
-  def proxy_response_start(res, tip, kcar, req_res)
+  def proxy_res_headers(res)
     status, headers = res
     code = status.to_i
     msg = Rack::Utils::HTTP_STATUS_CODES[code]
@@ -125,7 +121,15 @@ module Yahns::HttpResponse # :nodoc:
       wbuf = proxy_write(nil, res, alive)
       break # keep buffering as much as possible
     end while true
+    [ alive, wbuf, have_body ]
+  end
 
+  # start streaming the response once upstream is done sending headers to us.
+  # returns :wait_readable if we need to read more from req_res
+  # returns :ignore if we yield control to the client(self)
+  # returns nil if completely done
+  def proxy_response_start(res, tip, kcar, req_res)
+    alive, wbuf, have_body = proxy_res_headers(res)
     rbuf = Thread.current[:yahns_rbuf]
     tip = tip.empty? ? [] : [ tip ]