@@ -104,7 +104,7 @@ static int s_tester_init_ex(struct tester *tester, struct aws_allocator *alloc,
104104 tester -> alloc = alloc ;
105105
106106 struct aws_logger_standard_options logger_options = {
107- .level = AWS_LOG_LEVEL_TRACE ,
107+ .level = AWS_LOG_LEVEL_DEBUG ,
108108 .file = stderr ,
109109 };
110110 ASSERT_SUCCESS (aws_logger_init_standard (& tester -> logger , tester -> alloc , & logger_options ));
@@ -5607,3 +5607,106 @@ H1_CLIENT_TEST_CASE(h1_client_unified_write_data_api) {
56075607 ASSERT_SUCCESS (s_tester_clean_up (& tester ));
56085608 return AWS_OP_SUCCESS ;
56095609}
5610+
5611+ /* Test write_data with chunked encoding - single write */
5612+ H1_CLIENT_TEST_CASE (h1_client_write_data_chunked_single ) {
5613+ (void )ctx ;
5614+ struct tester tester ;
5615+ ASSERT_SUCCESS (s_tester_init (& tester , allocator ));
5616+
5617+ struct aws_http_message * request = s_new_default_chunked_put_request (allocator );
5618+
5619+ struct client_stream_tester stream_tester ;
5620+ ASSERT_SUCCESS (client_stream_tester_init (
5621+ & stream_tester ,
5622+ allocator ,
5623+ & (struct client_stream_tester_options ){
5624+ .request = request ,
5625+ .connection = tester .connection ,
5626+ .use_manual_data_writes = true,
5627+ }));
5628+
5629+ testing_channel_drain_queued_tasks (& tester .testing_channel );
5630+ aws_http_message_destroy (request );
5631+
5632+ struct aws_byte_cursor data = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("write more tests" );
5633+ struct aws_input_stream * input_stream = aws_input_stream_new_from_cursor (allocator , & data );
5634+
5635+ struct aws_http_stream_write_data_options write_options = {
5636+ .data = input_stream ,
5637+ .end_stream = true,
5638+ };
5639+
5640+ ASSERT_SUCCESS (aws_http_stream_write_data (stream_tester .stream , & write_options ));
5641+ testing_channel_drain_queued_tasks (& tester .testing_channel );
5642+
5643+ const char * expected = "PUT /plan.txt HTTP/1.1\r\n"
5644+ "Transfer-Encoding: chunked\r\n"
5645+ "\r\n"
5646+ "10\r\n"
5647+ "write more tests"
5648+ "\r\n"
5649+ "0\r\n"
5650+ "\r\n" ;
5651+ ASSERT_SUCCESS (testing_channel_check_written_messages_str (& tester .testing_channel , allocator , expected ));
5652+
5653+ aws_input_stream_release (input_stream );
5654+ client_stream_tester_clean_up (& stream_tester );
5655+ ASSERT_SUCCESS (s_tester_clean_up (& tester ));
5656+ return AWS_OP_SUCCESS ;
5657+ }
5658+
5659+ /* Test write_data with chunked encoding - multiple writes */
5660+ H1_CLIENT_TEST_CASE (h1_client_write_data_chunked_multiple ) {
5661+ (void )ctx ;
5662+ struct tester tester ;
5663+ ASSERT_SUCCESS (s_tester_init (& tester , allocator ));
5664+
5665+ struct aws_http_message * request = s_new_default_chunked_put_request (allocator );
5666+
5667+ struct client_stream_tester stream_tester ;
5668+ ASSERT_SUCCESS (client_stream_tester_init (
5669+ & stream_tester ,
5670+ allocator ,
5671+ & (struct client_stream_tester_options ){
5672+ .request = request ,
5673+ .connection = tester .connection ,
5674+ .use_manual_data_writes = true,
5675+ }));
5676+
5677+ testing_channel_drain_queued_tasks (& tester .testing_channel );
5678+ aws_http_message_destroy (request );
5679+
5680+ /* First write */
5681+ struct aws_byte_cursor data1 = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("write " );
5682+ struct aws_input_stream * stream1 = aws_input_stream_new_from_cursor (allocator , & data1 );
5683+ struct aws_http_stream_write_data_options opts1 = {.data = stream1 , .end_stream = false};
5684+ ASSERT_SUCCESS (aws_http_stream_write_data (stream_tester .stream , & opts1 ));
5685+
5686+ /* Second write with end_stream */
5687+ struct aws_byte_cursor data2 = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL ("more tests" );
5688+ struct aws_input_stream * stream2 = aws_input_stream_new_from_cursor (allocator , & data2 );
5689+ struct aws_http_stream_write_data_options opts2 = {.data = stream2 , .end_stream = true};
5690+ ASSERT_SUCCESS (aws_http_stream_write_data (stream_tester .stream , & opts2 ));
5691+
5692+ testing_channel_drain_queued_tasks (& tester .testing_channel );
5693+
5694+ const char * expected = "PUT /plan.txt HTTP/1.1\r\n"
5695+ "Transfer-Encoding: chunked\r\n"
5696+ "\r\n"
5697+ "6\r\n"
5698+ "write "
5699+ "\r\n"
5700+ "A\r\n"
5701+ "more tests"
5702+ "\r\n"
5703+ "0\r\n"
5704+ "\r\n" ;
5705+ ASSERT_SUCCESS (testing_channel_check_written_messages_str (& tester .testing_channel , allocator , expected ));
5706+
5707+ aws_input_stream_release (stream1 );
5708+ aws_input_stream_release (stream2 );
5709+ client_stream_tester_clean_up (& stream_tester );
5710+ ASSERT_SUCCESS (s_tester_clean_up (& tester ));
5711+ return AWS_OP_SUCCESS ;
5712+ }
0 commit comments