* [PATCH] proxy_pass: hoist out proxy_res_headers method
@ 2016-05-04 3:51 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-05-04 3:51 UTC (permalink / raw)
To: spew
proxy_response_start is gigantic an hard-to-read
---
lib/yahns/proxy_http_response.rb | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb
index c5e7be5..731bcd6 100644
--- a/lib/yahns/proxy_http_response.rb
+++ b/lib/yahns/proxy_http_response.rb
@@ -61,11 +61,7 @@ def wait_on_upstream(req_res, alive, wbuf)
: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]
@@ -121,7 +117,16 @@ def proxy_response_start(res, tip, kcar, req_res)
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)
+ res = nil # hopefully allow GC to release many header references
rbuf = Thread.current[:yahns_rbuf]
tip = tip.empty? ? [] : [ tip ]
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-05-04 3:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-04 3:51 [PATCH] proxy_pass: hoist out proxy_res_headers method Eric Wong
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).