Exemplo n.º 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"
     ]
Exemplo n.º 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"
Exemplo n.º 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"]
Exemplo n.º 4
0
 def test_unknown_size_limit(self):
     rfile = BytesIO(b"foobar")
     with raises(HttpException):
         b"".join(read_body(rfile, -1, 3))
Exemplo n.º 5
0
 def test_unknown_size(self):
     rfile = BytesIO(b"foobar")
     body = b"".join(read_body(rfile, -1))
     assert body == b"foobar"
Exemplo n.º 6
0
 def test_known_size_too_short(self):
     rfile = BytesIO(b"foo")
     with raises(HttpException):
         b"".join(read_body(rfile, 6))
Exemplo n.º 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"
Exemplo n.º 8
0
 def test_unknown_size(self):
     rfile = BytesIO(b"foobar")
     body = b"".join(read_body(rfile, -1))
     assert body == b"foobar"
Exemplo n.º 9
0
 def test_known_size_too_short(self):
     rfile = BytesIO(b"foo")
     with raises(HttpException):
         b"".join(read_body(rfile, 6))
Exemplo n.º 10
0
 def test_known_size_limit(self):
     rfile = BytesIO(b"foobar")
     with raises(HttpException):
         b"".join(read_body(rfile, 3, 2))
Exemplo n.º 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"
Exemplo n.º 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"