@@ -1351,9 +1351,12 @@ def data_callback(frame):
1351
1351
def test_connection_sends_rst_frame_if_frame_size_too_large (self ):
1352
1352
sock = DummySocket ()
1353
1353
d = DataFrame (1 )
1354
- # Create big data frame that exceeds the FRAME_MAX_LEN value in order
1355
- # to trigger the reset frame with error code 6 (FRAME_SIZE_ERROR)
1356
- d .data = b'' .join ([b"hi there sir" for x in range (40 )])
1354
+ # Receive oversized frame on the client side.
1355
+ # Create huge data frame that exceeds the FRAME_MAX_LEN value in order
1356
+ # to trigger the reset frame with error code 6 (FRAME_SIZE_ERROR).
1357
+ # FRAME_MAX_LEN is a constant value for the hyper client and cannot
1358
+ # be updated as of now.
1359
+ d .data = b'' .join ([b"hi there client" for x in range (40 )])
1357
1360
sock .buffer = BytesIO (d .serialize ())
1358
1361
1359
1362
frames = []
@@ -1375,7 +1378,7 @@ def send_rst_frame(stream_id, error_code):
1375
1378
assert f .stream_id == 1
1376
1379
assert f .error_code == 6 #FRAME_SIZE_ERROR
1377
1380
1378
- def test_connection_stream_is_removed_on_frame_size_error (self ):
1381
+ def test_connection_stream_is_removed_when_receiving_out_of_range_frame (self ):
1379
1382
sock = DummySocket ()
1380
1383
d = DataFrame (1 )
1381
1384
d .data = b'' .join ([b"hi there sir" for x in range (40 )])
@@ -1391,6 +1394,20 @@ def test_connection_stream_is_removed_on_frame_size_error(self):
1391
1394
c ._recv_cb ()
1392
1395
assert len (c .streams ) == 0
1393
1396
1397
+ def test_connection_error_when_send_out_of_range_frame (self ):
1398
+ # Send oversized frame to the server side.
1399
+ # Create huge data frame that exceeds the intitial FRAME_MAX_LEN setting
1400
+ # in order to trigger a value error when sending it.
1401
+ # Note that the value of the FRAME_MAX_LEN setting can be updated
1402
+ # by the server through a settings frame.
1403
+ d = DataFrame (1 )
1404
+ d .data = b'' .join ([b"hi there server" for x in range (1500 )])
1405
+
1406
+ c = HTTP20Connection ('www.google.com' )
1407
+ c ._sock = DummySocket ()
1408
+ with pytest .raises (ValueError ):
1409
+ c ._send_cb (d )
1410
+
1394
1411
# Some utility classes for the tests.
1395
1412
class NullEncoder (object ):
1396
1413
@staticmethod
0 commit comments