From ec786aa0df274bf66b7df209eade6a458009123c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 7 Apr 2015 03:16:58 +0000 Subject: proxy_pass: send 1.0 requests to upstreams for 1.0 clients 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. --- test/test_proxy_pass.rb | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'test/test_proxy_pass.rb') 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"] ] -- cgit v1.2.3-24-ge0c7