@@ -293,6 +293,61 @@ H2_DECODER_ON_CLIENT_TEST(h2_decoder_data_ignores_unknown_flags) {
293293 return AWS_OP_SUCCESS ;
294294}
295295
296+ H2_DECODER_ON_CLIENT_TEST (h2_decoder_data_payload_max_size_update ) {
297+ (void )allocator ;
298+ struct fixture * fixture = ctx ;
299+ /* The initial max size is set as 16384. Let's create a data frame with 16500 bytes data, and update the setting to
300+ * make it valid */
301+ aws_h2_decoder_set_setting_max_frame_size (fixture -> decode .decoder , 16500 );
302+ /* clang-format off */
303+ uint8_t input [16509 ] = {
304+ 0x00 , 0x40 , 0x74 , /* Length (24) */
305+ AWS_H2_FRAME_T_DATA , /* Type (8) */
306+ AWS_H2_FRAME_F_END_STREAM , /* Flags (8) */
307+ 0x76 , 0x54 , 0x32 , 0x10 , /* Reserved (1) | Stream Identifier (31) */
308+ /* DATA */
309+ };
310+ /* clang-format on */
311+ /* set the data and expected to 16500 'a' */
312+ char expected [16500 ];
313+ for (int i = 9 ; i < 16509 ; i ++ ) {
314+ input [i ] = 'a' ;
315+ expected [i - 9 ] = 'a' ;
316+ }
317+
318+ ASSERT_SUCCESS (s_decode_all (fixture , aws_byte_cursor_from_array (input , sizeof (input ))));
319+
320+ /* Validate. */
321+ struct h2_decoded_frame * frame = h2_decode_tester_latest_frame (& fixture -> decode );
322+ ASSERT_SUCCESS (h2_decoded_frame_check_finished (frame , AWS_H2_FRAME_T_DATA , 0x76543210 /*stream_id*/ ));
323+ ASSERT_SUCCESS (h2_decode_tester_check_data_across_frames (
324+ & fixture -> decode , 0x76543210 /*stream_id*/ , aws_byte_cursor_from_array (expected , 16500 ), true /*end_stream*/ ));
325+ return AWS_OP_SUCCESS ;
326+ }
327+
328+ /* The size of a frame payload is limited by the maximum size. An endpoint MUST send an error code of FRAME_SIZE_ERROR
329+ * if a frame exceeds the size */
330+ H2_DECODER_ON_CLIENT_TEST (h2_decoder_err_data_payload_exceed_max_size ) {
331+ (void )allocator ;
332+ struct fixture * fixture = ctx ;
333+ /* The initial max size is set as 16384. Let's create a data frame with 16500 bytes data, which will be invalid in
334+ * this case */
335+ /* clang-format off */
336+ uint8_t input [16509 ] = {
337+ 0x00 , 0x40 , 0x74 , /* Length (24) */
338+ AWS_H2_FRAME_T_DATA , /* Type (8) */
339+ AWS_H2_FRAME_F_END_STREAM , /* Flags (8) */
340+ 0x76 , 0x54 , 0x32 , 0x10 , /* Reserved (1) | Stream Identifier (31) */
341+ /* DATA */
342+ };
343+ /* clang-format on */
344+
345+ ASSERT_ERROR (
346+ AWS_ERROR_HTTP_INVALID_FRAME_SIZE , s_decode_all (fixture , aws_byte_cursor_from_array (input , sizeof (input ))));
347+
348+ return AWS_OP_SUCCESS ;
349+ }
350+
296351/* DATA frames MUST specify a stream-id */
297352H2_DECODER_ON_CLIENT_TEST (h2_decoder_err_data_requires_stream_id ) {
298353 (void )allocator ;
0 commit comments