From b079c1d346cba2d169006227cee8e9fa7fdab213 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 27 Apr 2016 00:27:00 +0000 Subject: test_proxy_pass: test for auto chunking on 1.0 backends These are followups to the following two commits: * commit d16326723d ("proxy_http_response: fix non-terminated fast responses, too") * commit 8c9f33a539 ("proxy_http_response: workaround non-terminated backends") --- test/test_proxy_pass.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/test_proxy_pass.rb b/test/test_proxy_pass.rb index 448e480..c938976 100644 --- a/test/test_proxy_pass.rb +++ b/test/test_proxy_pass.rb @@ -586,6 +586,21 @@ class TestProxyPass < Testcase assert_match %r{\AHTTP/1\.1 200 OK\r\n}, res assert_match %r{\r\n\r\neof-body-slow\z}, res s.close + + # we auto-chunk on 1.1 requests and 1.0 backends + %w(eof-body-slow eof-body-fast).each do |x| + s = TCPSocket.new(host, port) + s.write("GET /#{x} HTTP/1.1\r\nHost: example.com\r\n\r\n") + res = ''.dup + res << s.readpartial(512) until res =~ /0\r\n\r\n\z/ + s.close + head, body = res.split("\r\n\r\n", 2) + head = head.split("\r\n") + assert_equal 'HTTP/1.1 200 OK', head[0] + assert head.include?('Connection: keep-alive') + assert head.include?('Transfer-Encoding: chunked') + assert_match %r{\Ad\r\n#{x}\r\n0\r\n\r\n\z}, body + end end end -- cgit v1.2.3-24-ge0c7