示例#1
0
 def test_max_chunk_size(self):
     rfile = BytesIO(b"123456")
     assert list(read_body(rfile, -1, max_chunk_size=None)) == [b"123456"]
     rfile = BytesIO(b"123456")
     assert list(read_body(rfile, -1, max_chunk_size=1)) == [
         b"1", b"2", b"3", b"4", b"5", b"6"
     ]
示例#2
0
 def test_chunked(self):
     rfile = BytesIO(b"3\r\nfoo\r\n0\r\n\r\nbar")
     body = b"".join(read_body(rfile, None))
     assert body == b"foo"
     assert rfile.read() == b"bar"
示例#3
0
 def test_max_chunk_size(self):
     rfile = BytesIO(b"123456")
     assert list(read_body(rfile, -1, max_chunk_size=None)) == [b"123456"]
     rfile = BytesIO(b"123456")
     assert list(read_body(rfile, -1, max_chunk_size=1)) == [b"1", b"2", b"3", b"4", b"5", b"6"]
示例#4
0
 def test_unknown_size_limit(self):
     rfile = BytesIO(b"foobar")
     with raises(HttpException):
         b"".join(read_body(rfile, -1, 3))
示例#5
0
 def test_unknown_size(self):
     rfile = BytesIO(b"foobar")
     body = b"".join(read_body(rfile, -1))
     assert body == b"foobar"
示例#6
0
 def test_known_size_too_short(self):
     rfile = BytesIO(b"foo")
     with raises(HttpException):
         b"".join(read_body(rfile, 6))
示例#7
0
 def test_known_size(self):
     rfile = BytesIO(b"foobar")
     body = b"".join(read_body(rfile, 3))
     assert body == b"foo"
     assert rfile.read() == b"bar"
示例#8
0
 def test_unknown_size(self):
     rfile = BytesIO(b"foobar")
     body = b"".join(read_body(rfile, -1))
     assert body == b"foobar"
示例#9
0
 def test_known_size_too_short(self):
     rfile = BytesIO(b"foo")
     with raises(HttpException):
         b"".join(read_body(rfile, 6))
示例#10
0
 def test_known_size_limit(self):
     rfile = BytesIO(b"foobar")
     with raises(HttpException):
         b"".join(read_body(rfile, 3, 2))
示例#11
0
 def test_known_size(self):
     rfile = BytesIO(b"foobar")
     body = b"".join(read_body(rfile, 3))
     assert body == b"foo"
     assert rfile.read() == b"bar"
示例#12
0
 def test_chunked(self):
     rfile = BytesIO(b"3\r\nfoo\r\n0\r\n\r\nbar")
     body = b"".join(read_body(rfile, None))
     assert body == b"foo"
     assert rfile.read() == b"bar"