about summary refs log tree commit homepage
path: root/test/test_proxy_pass.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-04-07 03:16:58 +0000
committerEric Wong <e@80x24.org>2015-04-07 06:49:41 +0000
commitec786aa0df274bf66b7df209eade6a458009123c (patch)
tree6a061065e635b0b8fb9d7335a18890320b6a7192 /test/test_proxy_pass.rb
parentaec9f8095070a746ee44b8e85061141b7253c6ce (diff)
downloadyahns-ec786aa0df274bf66b7df209eade6a458009123c.tar.gz
We cannot pass trailers from upstreams to HTTP/1.0 clients without
fully-buffering the response body AND trailers before forwarding the
response header.

Of course, one of the reasons yahns exists is to support lazy
buffering, so fully-buffering up front is wasteful and hurts
latency.  So instead, degrade to 1.0 requests to upstreams for
HTTP/1.0 clients, this should prevent upstreams from sending
trailers in the first place.

HTTP/1.0 clients on Rails apps may suffer, but there probably
are not too many HTTP/1.0 clients out there.
Diffstat (limited to 'test/test_proxy_pass.rb')
-rw-r--r--test/test_proxy_pass.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/test/test_proxy_pass.rb b/test/test_proxy_pass.rb
index 943fb35..c1539f8 100644
--- a/test/test_proxy_pass.rb
+++ b/test/test_proxy_pass.rb
@@ -86,13 +86,23 @@ class TestProxyPass < Testcase
           delay = $1.to_f
           chunky = Object.new
           chunky.instance_variable_set(:@delay, delay)
-          def chunky.each
-            sleep @delay
-            yield "3\r\nHI!\r\n"
-            sleep @delay
-            yield "0\r\n\r\n"
+          if env['HTTP_VERSION'] == 'HTTP/1.0'
+            h = [ %w(Content-Type text/pain), %w(Content-Length 3) ]
+            def chunky.each
+              %w(H I !).each do |x|
+                sleep @delay
+                yield x
+              end
+            end
+          else
+            h = [ %w(Content-Type text/pain), %w(Transfer-Encoding chunked) ]
+            def chunky.each
+              sleep @delay
+              yield "3\r\nHI!\r\n"
+              sleep @delay
+              yield "0\r\n\r\n"
+            end
           end
-          h = [ %w(Content-Type text/pain), %w(Transfer-Encoding chunked) ]
           [ 200, h, chunky ]
         else
           [ 200, h, [ "hi\n"] ]