diff options
author | Eric Wong <e@80x24.org> | 2015-04-07 03:16:58 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-04-07 06:49:41 +0000 |
commit | ec786aa0df274bf66b7df209eade6a458009123c (patch) | |
tree | 6a061065e635b0b8fb9d7335a18890320b6a7192 /lib/yahns/proxy_pass.rb | |
parent | aec9f8095070a746ee44b8e85061141b7253c6ce (diff) | |
download | yahns-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 'lib/yahns/proxy_pass.rb')
-rw-r--r-- | lib/yahns/proxy_pass.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/yahns/proxy_pass.rb b/lib/yahns/proxy_pass.rb index 3812dbf..e3ba7f0 100644 --- a/lib/yahns/proxy_pass.rb +++ b/lib/yahns/proxy_pass.rb @@ -205,7 +205,13 @@ class Yahns::ProxyPass # :nodoc: req = @path.gsub(/\$(\w+)/) { req.__send__($1) } # start the connection asynchronously and early so TCP can do a - req = "#{env['REQUEST_METHOD']} #{req} HTTP/1.1\r\n" \ + case ver = env['HTTP_VERSION'] + when 'HTTP/1.1' # leave alone, response may be chunked + else # no chunking for HTTP/1.0 and HTTP/0.9 + ver = 'HTTP/1.0'.freeze + end + + req = "#{env['REQUEST_METHOD']} #{req} #{ver}\r\n" \ "X-Forwarded-For: #{env["REMOTE_ADDR"]}\r\n" # pass most HTTP_* headers through as-is |