about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-04-21 23:52:13 +0000
committerEric Wong <e@80x24.org>2016-04-23 04:42:03 +0000
commitd16326723dcbc0a58e5a91078eac6a6058441702 (patch)
tree24ad702c4df69546676b41998db4c66ef070c711
parent8d7af351b76389eac236dcc2fb024272f92166aa (diff)
downloadyahns-d16326723dcbc0a58e5a91078eac6a6058441702.tar.gz
Without this, non-terminated backends were not properly
supported if they gave tiny responses or responded faster
than we could stream the response to the client.

This is necessary to support fast responses from some non-Rack
HTTP/1.0-only backend servers which rely on connection
termination to terminate responses.

Tested manually with a Perl PSGI application running under
"plackup".  Unlike Rack, the PSGI spec does not specify whether
the PSGI application or PSGI server should handle response
termination: git clone https://github.com/plack/psgi-specs.git

Follow-up-to: 8c9f33a5396d2 ("workaround non-terminated backends")
-rw-r--r--lib/yahns/proxy_http_response.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb
index a23c21d..c8a2a42 100644
--- a/lib/yahns/proxy_http_response.rb
+++ b/lib/yahns/proxy_http_response.rb
@@ -168,6 +168,7 @@ module Yahns::HttpResponse # :nodoc:
           tmp = chunk_out(tmp) if alive
           wbuf = proxy_write(wbuf, tmp, alive)
         when nil
+          wbuf = proxy_write(wbuf, "0\r\n\r\n".freeze, true) if alive
           req_res.shutdown
           break
         when :wait_readable