@@ -60,6 +60,7 @@ struct stub_config {
60
60
typedef websocketpp::extensions::permessage_deflate::disabled
61
61
<permessage_deflate_config> permessage_deflate_type;
62
62
63
+ static const size_t max_message_size = 16000000 ;
63
64
static const bool enable_extensions = false ;
64
65
};
65
66
@@ -81,6 +82,7 @@ struct stub_config_ext {
81
82
typedef websocketpp::extensions::permessage_deflate::enabled
82
83
<permessage_deflate_config> permessage_deflate_type;
83
84
85
+ static const size_t max_message_size = 16000000 ;
84
86
static const bool enable_extensions = true ;
85
87
};
86
88
@@ -489,6 +491,36 @@ BOOST_AUTO_TEST_CASE( prepare_data_frame ) {
489
491
490
492
}
491
493
494
+ BOOST_AUTO_TEST_CASE ( single_frame_message_too_large ) {
495
+ processor_setup env (true );
496
+
497
+ env.p .set_max_message_size (3 );
498
+
499
+ uint8_t frame0[10 ] = {0x82 , 0x84 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x01 , 0x01 , 0x01 };
500
+
501
+ // read message that is one byte too large
502
+ BOOST_CHECK_EQUAL ( env.p .consume (frame0,10 ,env.ec ), 6 );
503
+ BOOST_CHECK_EQUAL ( env.ec , websocketpp::processor::error::message_too_big );
504
+ }
505
+
506
+ BOOST_AUTO_TEST_CASE ( multiple_frame_message_too_large ) {
507
+ processor_setup env (true );
508
+
509
+ env.p .set_max_message_size (4 );
510
+
511
+ uint8_t frame0[8 ] = {0x02 , 0x82 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x01 };
512
+ uint8_t frame1[9 ] = {0x80 , 0x83 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x01 , 0x01 };
513
+
514
+ // read first message frame with size under the limit
515
+ BOOST_CHECK_EQUAL ( env.p .consume (frame0,8 ,env.ec ), 8 );
516
+ BOOST_CHECK ( !env.ec );
517
+
518
+ // read second message frame that puts the size over the limit
519
+ BOOST_CHECK_EQUAL ( env.p .consume (frame1,9 ,env.ec ), 6 );
520
+ BOOST_CHECK_EQUAL ( env.ec , websocketpp::processor::error::message_too_big );
521
+ }
522
+
523
+
492
524
493
525
BOOST_AUTO_TEST_CASE ( client_handshake_request ) {
494
526
processor_setup env (false );
0 commit comments