From a45c6246933f7eb05fafbfcdc233a42e64947acb Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 4 Nov 2009 23:01:53 -0800 Subject: http: extra test for bytewise chunked bodies Make sure we're completely resumable no matter how idiotic clients are. --- test/unit/test_http_parser_ng.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test') 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" \ -- cgit v1.2.3-24-ge0c7