about summary refs log tree commit homepage
path: root/test/http_put.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/http_put.rb')
-rw-r--r--test/http_put.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/http_put.rb b/test/http_put.rb
index 0479629..34e2cdb 100644
--- a/test/http_put.rb
+++ b/test/http_put.rb
@@ -226,6 +226,22 @@ class TestHTTPPut < Test::Unit::TestCase
     assert( ! File.exist?("#@tmpdir/dev666/foo") )
   end
 
+  def test_put_favors_chunked
+    order = [ "Transfer-Encoding: chunked", "Content-Length: 123" ]
+    %w[a b].each do
+      path = '/dev666/a'
+      req = "PUT #{path} HTTP/1.1\r\n" \
+            "#{order.join("\r\n")}\r\n\r\n" \
+            "a\r\nhelloworld\r\n0\r\n\r\n"
+      order.reverse!
+      @client.write(req)
+      resp = @client.readpartial(4096)
+      assert_match(%r{\AHTTP/1\.1 201 Created\r\n}, resp, "#{path} created")
+      assert(File.exist?("#@tmpdir#{path}"))
+      assert_equal('helloworld', File.read("#@tmpdir#{path}"))
+    end
+  end
+
   def test_content_md5_good
     req = "PUT /dev666/foo HTTP/1.1\r\n" \
           "Host: #@host:#@port\r\n" \