about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-04 23:01:53 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-04 23:01:53 -0800
commita45c6246933f7eb05fafbfcdc233a42e64947acb (patch)
tree2728b62c972725f9938de8557a2b94f8e32eac0e /test
parent2c9cbe383ce8049707eda87c632855995a65e032 (diff)
downloadunicorn-a45c6246933f7eb05fafbfcdc233a42e64947acb.tar.gz
Make sure we're completely resumable no matter how
idiotic clients are.
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_http_parser_ng.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/unit/test_http_parser_ng.rb b/test/unit/test_http_parser_ng.rb
index 0167f8f..e84c765 100644
--- a/test/unit/test_http_parser_ng.rb
+++ b/test/unit/test_http_parser_ng.rb
@@ -190,6 +190,26 @@ class HttpParserNgTest < Test::Unit::TestCase
     assert ! @parser.keepalive?
   end
 
+  def test_chunks_bytewise
+    chunked = "10\r\nabcdefghijklmnop\r\n11\r\n0123456789abcdefg\r\n0\r\n"
+    str = "PUT / HTTP/1.1\r\ntransfer-Encoding: chunked\r\n\r\n#{chunked}"
+    req = {}
+    assert_equal req, @parser.headers(req, str)
+    assert_equal chunked, str
+    tmp = ''
+    buf = ''
+    body = ''
+    str = str[0..-2]
+    str.each_byte { |byte|
+      assert_nil @parser.filter_body(tmp, buf << byte.chr)
+      body << tmp
+    }
+    assert_equal 'abcdefghijklmnop0123456789abcdefg', body
+    rv = @parser.filter_body(tmp, buf << "\n")
+    assert_equal rv.object_id, buf.object_id
+    assert ! @parser.keepalive?
+  end
+
   def test_trailers
     str = "PUT / HTTP/1.1\r\n" \
           "Trailer: Content-MD5\r\n" \