diff --git a/tests/main.c b/tests/main.c index 99a72d76..ec7f7eea 100644 --- a/tests/main.c +++ b/tests/main.c @@ -257,6 +257,8 @@ int main(int argc _U_, char *argv[] _U_) { test_nghttp2_session_open_idle_stream) || !CU_add_test(pSuite, "session_cancel_reserved_remote", test_nghttp2_session_cancel_reserved_remote) || + !CU_add_test(pSuite, "session_reset_pending_headers", + test_nghttp2_session_reset_pending_headers) || !CU_add_test(pSuite, "frame_pack_headers", test_nghttp2_frame_pack_headers) || !CU_add_test(pSuite, "frame_pack_headers_frame_too_large", diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 1eda9a2e..6abf6702 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -6753,3 +6753,36 @@ void test_nghttp2_session_cancel_reserved_remote(void) { nghttp2_bufs_free(&bufs); } + +void test_nghttp2_session_reset_pending_headers(void) { + nghttp2_session *session; + nghttp2_session_callbacks callbacks; + nghttp2_stream *stream; + int32_t stream_id; + + memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); + callbacks.send_callback = null_send_callback; + + nghttp2_session_client_new(&session, &callbacks, NULL); + + /* See that if request HEADERS and RST_STREAM were submitted in this + order, HEADERS is sent first. This is useful feature since + client can issue RST_STREAM in things go wrong while preparing + data for HEADERS, but this may be rare in practice. On the other + hand, we don't have same property for PUSH_PROMISE and RST_STREAM + to reserved stream. We may fix this if this is a significant + problem. */ + stream_id = nghttp2_submit_request(session, NULL, NULL, 0, NULL, NULL); + CU_ASSERT(stream_id >= 1); + + nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, stream_id, + NGHTTP2_NO_ERROR); + + CU_ASSERT(0 == nghttp2_session_send(session)); + + stream = nghttp2_session_get_stream(session, stream_id); + + CU_ASSERT(NULL == stream); + + nghttp2_session_del(session); +} diff --git a/tests/nghttp2_session_test.h b/tests/nghttp2_session_test.h index cc09e7de..3e64c8e7 100644 --- a/tests/nghttp2_session_test.h +++ b/tests/nghttp2_session_test.h @@ -121,5 +121,6 @@ void test_nghttp2_session_recv_client_preface(void); void test_nghttp2_session_delete_data_item(void); void test_nghttp2_session_open_idle_stream(void); void test_nghttp2_session_cancel_reserved_remote(void); +void test_nghttp2_session_reset_pending_headers(void); #endif /* NGHTTP2_SESSION_TEST_H */