Add test for submission ordering of HEADERS and its RST_STREAM

This commit is contained in:
Tatsuhiro Tsujikawa 2015-02-12 21:28:20 +09:00
parent 354de30874
commit 7d4a6aa179
3 changed files with 36 additions and 0 deletions

View File

@ -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",

View File

@ -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);
}

View File

@ -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 */