about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-04-03 22:17:45 +0000
committerEric Wong <e@80x24.org>2015-04-03 22:17:45 +0000
commit58936a8f4d3e9895f80fe092753c0a1c3eb4ac40 (patch)
tree6f5a6b839e016e11c3dff23f91002a977588bfb2 /test
parentb537f61726c89dd4d0020041f521c66f2046f000 (diff)
downloadyahns-58936a8f4d3e9895f80fe092753c0a1c3eb4ac40.tar.gz
Pipelining uploads is rare in practice, but they must behave
properly in case some brave soul wants to start doing it.
Diffstat (limited to 'test')
-rw-r--r--test/test_proxy_pass.rb51
1 files 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 @@ class TestProxyPass < Testcase
         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: / }