@@ -5422,6 +5422,70 @@ TEST_CASE(h2_client_manual_data_write) {
54225422 return s_tester_clean_up ();
54235423}
54245424
5425+ static void s_http_stream_write_complete_fn (struct aws_http_stream * stream , int error_code , void * user_data ) {
5426+ (void )stream ;
5427+ int * ctx = (int * )user_data ;
5428+ * ctx = error_code ;
5429+ }
5430+
5431+ TEST_CASE (h2_client_manual_data_write_read_broken ) {
5432+
5433+ ASSERT_SUCCESS (s_tester_init (allocator , ctx ));
5434+ /* get connection preface and acks out of the way */
5435+ ASSERT_SUCCESS (h2_fake_peer_send_connection_preface_default_settings (& s_tester .peer ));
5436+ ASSERT_SUCCESS (h2_fake_peer_decode_messages_from_testing_channel (& s_tester .peer ));
5437+
5438+ struct aws_http_message * request = aws_http2_message_new_request (allocator );
5439+ ASSERT_NOT_NULL (request );
5440+
5441+ struct aws_http_header request_headers_src [] = {
5442+ DEFINE_HEADER (":method" , "POST" ),
5443+ DEFINE_HEADER (":scheme" , "https" ),
5444+ DEFINE_HEADER (":path" , "/" ),
5445+ };
5446+ aws_http_message_add_header_array (request , request_headers_src , AWS_ARRAY_SIZE (request_headers_src ));
5447+ struct client_stream_tester stream_tester ;
5448+
5449+ struct client_stream_tester_options options = {
5450+ .request = request ,
5451+ .connection = s_tester .connection ,
5452+ .http2_manual_write = true,
5453+ };
5454+ ASSERT_SUCCESS (client_stream_tester_init (& stream_tester , s_tester .alloc , & options ));
5455+ struct aws_http_stream * stream = stream_tester .stream ;
5456+ ASSERT_NOT_NULL (stream );
5457+
5458+ testing_channel_drain_queued_tasks (& s_tester .testing_channel );
5459+
5460+ struct aws_input_stream * data_stream = aws_input_stream_new_tester (allocator , aws_byte_cursor_from_c_str ("abcd" ));
5461+ aws_input_stream_tester_set_reading_broken (data_stream , true);
5462+ int error_code = 0 ;
5463+ struct aws_http2_stream_write_data_options write = {
5464+ .data = data_stream ,
5465+ .on_complete = s_http_stream_write_complete_fn ,
5466+ .user_data = & error_code ,
5467+ };
5468+
5469+ ASSERT_SUCCESS (aws_http2_stream_write_data (stream , & write ));
5470+ aws_input_stream_release (data_stream );
5471+
5472+ testing_channel_drain_queued_tasks (& s_tester .testing_channel );
5473+ ASSERT_TRUE (stream_tester .complete );
5474+ /* The stream complete will get the error code from the input stream read. */
5475+ ASSERT_UINT_EQUALS (stream_tester .on_complete_error_code , AWS_IO_STREAM_READ_FAILED );
5476+ /* The write triggers the stream to complete with error, so the write failed as the stream completes. */
5477+ ASSERT_UINT_EQUALS (error_code , AWS_ERROR_HTTP_STREAM_HAS_COMPLETED );
5478+
5479+ aws_http_message_release (request );
5480+
5481+ /* close the connection */
5482+ aws_http_connection_close (s_tester .connection );
5483+ client_stream_tester_clean_up (& stream_tester );
5484+
5485+ /* clean up */
5486+ return s_tester_clean_up ();
5487+ }
5488+
54255489TEST_CASE (h2_client_manual_data_write_not_enabled ) {
54265490
54275491 ASSERT_SUCCESS (s_tester_init (allocator , ctx ));
0 commit comments