Pipelining uploads is rare in practice, but they must behave
properly in case some brave soul wants to start doing it.
---
 test/test_proxy_pass.rb | 51 +++++++++++++++++++++++++++++++++++--------------
 1 file changed, 37 insertions(+), 14 deletions(-)

diff --git a/test/test_proxy_pass.rb b/test/test_proxy_pass.rb
index cebd004..163a0f7 100644
--- a/test/test_proxy_pass.rb
+++ b/test/test_proxy_pass.rb
@@ -286,21 +286,44 @@ def check_pipelining(host, port)
         r2 << pl.readpartial(666)
       end
 
-      if false
-        pl.write "ET / HTTP/1.1\r\nHost: example.com\r\n\r\n"
-        until r3 =~ /hi\n/
-          r3 << pl.readpartial(666)
-        end
-      else
-        pl.write "UT / HTTP/1.1\r\nHost: example.com\r\n"
-        pl.write "Transfer-Encoding: chunked\r\n\r\n"
-        pl.write "6\r\nchunky\r\n"
-        pl.write "0\r\n\r\n"
-
-        until r3 =~ /chunky/
-          r3 << pl.readpartial(666)
-        end
+      pl.write "UT / HTTP/1.1\r\nHost: example.com\r\n"
+      pl.write "Transfer-Encoding: chunked\r\n\r\n"
+      pl.write "6\r\nchunky\r\n"
+      pl.write "0\r\n\r\n"
+
+      until r3 =~ /chunky/
+        r3 << pl.readpartial(666)
+      end
+
+      # ensure stuff still works after a chunked upload:
+      pl.write "GET / HTTP/1.1\r\nHost: example.com\r\n\r\nP"
+      after_up = ''
+      until after_up =~ /hi\n/
+        after_up << pl.readpartial(666)
+      end
+      re = /^Date:[^\r\n]+/
+      assert_equal after_up.sub(re, ''), r1.sub(re, '')
+
+      # another upload, this time without chunking
+      pl.write "UT / HTTP/1.1\r\nHost: example.com\r\n"
+      pl.write "Content-Length: 8\r\n\r\n"
+      pl.write "identity"
+      identity = ''
+
+      until identity =~ /identity/
+        identity << pl.readpartial(666)
+      end
+      assert_match %r{identity\z}, identity
+      assert_match %r{\AHTTP/1\.1 201\b}, identity
+
+      # ensure stuff still works after an identity upload:
+      pl.write "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n"
+      after_up = ''
+      until after_up =~ /hi\n/
+        after_up << pl.readpartial(666)
       end
+      re = /^Date:[^\r\n]+/
+      assert_equal after_up.sub(re, ''), r1.sub(re, '')
     end
     r1 = r1.split("\r\n").reject { |x| x =~ /^Date: / }
     r2 = r2.split("\r\n").reject { |x| x =~ /^Date: / }
-- 
EW


Reply via email to