@@ -230,6 +230,23 @@ TEST_CASE(h2_client_stream_release_after_complete) {
230
230
return s_tester_clean_up ();
231
231
}
232
232
233
+ struct s_callback_invoked {
234
+ bool destroy_invoked ;
235
+ bool complete_invoked ;
236
+ };
237
+
238
+ static void s_unactivated_stream_cleans_up_on_destroy (void * data ) {
239
+ struct s_callback_invoked * callback_data = data ;
240
+ callback_data -> destroy_invoked = true;
241
+ }
242
+
243
+ static void s_unactivated_stream_complete (struct aws_http_stream * stream , int error_code , void * data ) {
244
+ (void )stream ;
245
+ (void )error_code ;
246
+ struct s_callback_invoked * callback_data = data ;
247
+ callback_data -> complete_invoked = true;
248
+ }
249
+
233
250
TEST_CASE (h2_client_unactivated_stream_cleans_up ) {
234
251
ASSERT_SUCCESS (s_tester_init (allocator , ctx ));
235
252
@@ -243,22 +260,30 @@ TEST_CASE(h2_client_unactivated_stream_cleans_up) {
243
260
DEFINE_HEADER (":path" , "/" ),
244
261
};
245
262
ASSERT_SUCCESS (aws_http_message_add_header_array (request , headers , AWS_ARRAY_SIZE (headers )));
246
-
263
+ struct s_callback_invoked callback_data = { 0 };
247
264
struct aws_http_make_request_options options = {
248
265
.self_size = sizeof (options ),
249
266
.request = request ,
267
+ .on_destroy = s_unactivated_stream_cleans_up_on_destroy ,
268
+ .on_complete = s_unactivated_stream_complete ,
269
+ .user_data = & callback_data ,
250
270
};
251
271
252
272
struct aws_http_stream * stream = aws_http_connection_make_request (s_tester .connection , & options );
253
273
ASSERT_NOT_NULL (stream );
254
274
/* do not activate the stream, that's the test. */
255
275
276
+ ASSERT_FALSE (callback_data .destroy_invoked );
277
+ ASSERT_FALSE (callback_data .complete_invoked );
256
278
/* shutdown channel so request can be released */
257
279
aws_channel_shutdown (s_tester .testing_channel .channel , AWS_ERROR_SUCCESS );
258
280
testing_channel_drain_queued_tasks (& s_tester .testing_channel );
259
281
ASSERT_TRUE (testing_channel_is_shutdown_completed (& s_tester .testing_channel ));
260
282
261
283
aws_http_stream_release (stream );
284
+ ASSERT_TRUE (callback_data .destroy_invoked );
285
+ ASSERT_FALSE (callback_data .complete_invoked );
286
+
262
287
aws_http_message_release (request );
263
288
264
289
return s_tester_clean_up ();
@@ -1074,7 +1099,7 @@ TEST_CASE(h2_client_stream_err_receive_info_headers_after_main) {
1074
1099
ASSERT_SUCCESS (h2_fake_peer_send_frame (& s_tester .peer , peer_frame ));
1075
1100
1076
1101
testing_channel_drain_queued_tasks (& s_tester .testing_channel );
1077
- /* validate the stream compeleted with error */
1102
+ /* validate the stream completed with error */
1078
1103
ASSERT_TRUE (stream_tester .complete );
1079
1104
ASSERT_INT_EQUALS (AWS_ERROR_HTTP_PROTOCOL_ERROR , stream_tester .on_complete_error_code );
1080
1105
/* validate the connection is not affected */
@@ -1196,7 +1221,7 @@ TEST_CASE(h2_client_stream_err_receive_trailing_before_main) {
1196
1221
ASSERT_SUCCESS (h2_fake_peer_send_frame (& s_tester .peer , peer_frame ));
1197
1222
1198
1223
testing_channel_drain_queued_tasks (& s_tester .testing_channel );
1199
- /* validate the stream compeleted with error */
1224
+ /* validate the stream completed with error */
1200
1225
ASSERT_TRUE (stream_tester .complete );
1201
1226
ASSERT_INT_EQUALS (AWS_ERROR_HTTP_PROTOCOL_ERROR , stream_tester .on_complete_error_code );
1202
1227
/* validate the connection is not affected */
@@ -1321,7 +1346,7 @@ TEST_CASE(h2_client_stream_err_stream_frames_received_soon_after_rst_stream_rece
1321
1346
peer_frame = aws_h2_frame_new_headers (allocator , stream_id , response_headers , true /*end_stream*/ , 0 , NULL );
1322
1347
ASSERT_SUCCESS (h2_fake_peer_send_frame (& s_tester .peer , peer_frame ));
1323
1348
testing_channel_drain_queued_tasks (& s_tester .testing_channel );
1324
- /* validate the stream compeleted with error */
1349
+ /* validate the stream completed with error */
1325
1350
ASSERT_TRUE (stream_tester .complete );
1326
1351
ASSERT_INT_EQUALS (AWS_ERROR_HTTP_RST_STREAM_RECEIVED , stream_tester .on_complete_error_code );
1327
1352
/* We treat this as a stream error. So, validate the connection is still open and a rst stream is sent by
0 commit comments