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-08 06:09:40 +0000
committerEric Wong <e@80x24.org>2015-04-08 06:15:57 +0000
commitdf92940cc9afdd8a95301734c2c79471ed861c9a (patch)
treedb402b48a46674f65fa2b1a17aca1f7d6de5e819 /test/test_proxy_pass.rb
parent4be7ef88930937eadc362c41bd82ebbf564e6a03 (diff)
downloadyahns-df92940cc9afdd8a95301734c2c79471ed861c9a.tar.gz
Not all backends are capable of generating chunked responses
(especially not to HTTP/1.0 clients) nor can they generate
the Content-Length (especially when gzipping), so they'll
close the socket to signal EOF instead.
Diffstat (limited to 'test/test_proxy_pass.rb')
-rw-r--r--test/test_proxy_pass.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/test_proxy_pass.rb b/test/test_proxy_pass.rb
index e4e97d1..eb866b3 100644
--- a/test/test_proxy_pass.rb
+++ b/test/test_proxy_pass.rb
@@ -65,6 +65,16 @@ class TestProxyPass < Testcase
           io = env['rack.hijack'].call
           io.write(TRUNCATE_BODY)
           io.close
+        when '/eof-body-fast'
+          io = env['rack.hijack'].call
+          io.write("HTTP/1.0 200 OK\r\n\r\neof-body-fast")
+          io.close
+        when '/eof-body-slow'
+          io = env['rack.hijack'].call
+          io.write("HTTP/1.0 200 OK\r\n\r\n")
+          sleep 0.1
+          io.write("eof-body-slow")
+          io.close
         when '/truncate-head'
           io = env['rack.hijack'].call
           io.write(TRUNCATE_HEAD)
@@ -244,6 +254,7 @@ class TestProxyPass < Testcase
       end
     end
 
+    check_eof_body(host, port)
     check_pipelining(host, port)
     check_response_trailer(host, port)
 
@@ -531,4 +542,22 @@ class TestProxyPass < Testcase
     end
     thrs.each { |t| assert_equal(:OK, t.value) }
   end
+
+  def check_eof_body(host, port)
+    Timeout.timeout(60) do
+      s = TCPSocket.new(host, port)
+      s.write("GET /eof-body-fast HTTP/1.0\r\n\r\n")
+      res = s.read
+      assert_match %r{\AHTTP/1\.1 200 OK\r\n}, res
+      assert_match %r{\r\n\r\neof-body-fast\z}, res
+      s.close
+
+      s = TCPSocket.new(host, port)
+      s.write("GET /eof-body-slow HTTP/1.0\r\n\r\n")
+      res = s.read
+      assert_match %r{\AHTTP/1\.1 200 OK\r\n}, res
+      assert_match %r{\r\n\r\neof-body-slow\z}, res
+      s.close
+    end
+  end
 end