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