diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 241c7cd4..909907ab 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -559,7 +559,7 @@ static int nghttp2_predicate_stream_for_send(nghttp2_stream *stream) * Stream ID has reached the maximum value. Therefore no stream ID * is available. */ -static int nghttp2_session_predicate_syn_stream_send +static int nghttp2_session_predicate_request_headers_send (nghttp2_session *session, nghttp2_headers *frame) { if(session->goaway_flags) { @@ -594,8 +594,8 @@ static int nghttp2_session_predicate_syn_stream_send * The state of the stream is not valid (e.g., SYN_REPLY has * already sent). */ -static int nghttp2_session_predicate_syn_reply_send(nghttp2_session *session, - int32_t stream_id) +static int nghttp2_session_predicate_response_headers_send +(nghttp2_session *session, int32_t stream_id) { nghttp2_stream *stream = nghttp2_session_get_stream(session, stream_id); int r; @@ -633,8 +633,8 @@ static int nghttp2_session_predicate_syn_reply_send(nghttp2_session *session, * NGHTTP2_ERR_STREAM_CLOSED * RST_STREAM was queued for this stream. */ -static int nghttp2_session_predicate_push_reply_send(nghttp2_session *session, - int32_t stream_id) +static int nghttp2_session_predicate_push_response_headers_send +(nghttp2_session *session, int32_t stream_id) { nghttp2_stream *stream = nghttp2_session_get_stream(session, stream_id); int r; @@ -906,17 +906,17 @@ static ssize_t nghttp2_session_prep_frame(nghttp2_session *session, /* initial HEADERS, which opens stream */ int r; frame->headers.cat = NGHTTP2_HCAT_REQUEST; - r = nghttp2_session_predicate_syn_stream_send(session, - &frame->headers); + r = nghttp2_session_predicate_request_headers_send(session, + &frame->headers); if(r != 0) { return r; } frame->hd.stream_id = session->next_stream_id; session->next_stream_id += 2; - } else if(nghttp2_session_predicate_push_reply_send + } else if(nghttp2_session_predicate_push_response_headers_send (session, frame->hd.stream_id) == 0) { frame->headers.cat = NGHTTP2_HCAT_PUSH_RESPONSE; - } else if(nghttp2_session_predicate_syn_reply_send + } else if(nghttp2_session_predicate_response_headers_send (session, frame->hd.stream_id) == 0) { frame->headers.cat = NGHTTP2_HCAT_RESPONSE; } else { @@ -1654,8 +1654,8 @@ static int nghttp2_session_handle_invalid_connection return nghttp2_session_fail_session(session, error_code); } -int nghttp2_session_on_syn_stream_received(nghttp2_session *session, - nghttp2_frame *frame) +int nghttp2_session_on_request_headers_received(nghttp2_session *session, + nghttp2_frame *frame) { int r = 0; nghttp2_error_code error_code = NGHTTP2_NO_ERROR; @@ -1702,9 +1702,9 @@ int nghttp2_session_on_syn_stream_received(nghttp2_session *session, return r; } -int nghttp2_session_on_syn_reply_received(nghttp2_session *session, - nghttp2_frame *frame, - nghttp2_stream *stream) +int nghttp2_session_on_response_headers_received(nghttp2_session *session, + nghttp2_frame *frame, + nghttp2_stream *stream) { /* This function is only called if stream->state == NGHTTP2_STREAM_OPENING and stream_id is local side initiated. */ @@ -1736,9 +1736,9 @@ int nghttp2_session_on_syn_reply_received(nghttp2_session *session, return 0; } -int nghttp2_session_on_push_reply_received(nghttp2_session *session, - nghttp2_frame *frame, - nghttp2_stream *stream) +int nghttp2_session_on_push_response_headers_received(nghttp2_session *session, + nghttp2_frame *frame, + nghttp2_stream *stream) { int rv = 0; assert(!session->server && stream->state == NGHTTP2_STREAM_RESERVED); @@ -2275,7 +2275,8 @@ static int nghttp2_session_process_ctrl_frame(nghttp2_session *session) if(nghttp2_session_is_my_stream_id(session, frame.hd.stream_id)) { if(stream->state == NGHTTP2_STREAM_OPENING) { frame.headers.cat = NGHTTP2_HCAT_RESPONSE; - r = nghttp2_session_on_syn_reply_received(session, &frame, stream); + r = nghttp2_session_on_response_headers_received + (session, &frame, stream); } else { frame.headers.cat = NGHTTP2_HCAT_HEADERS; r = nghttp2_session_on_headers_received(session, &frame, stream); @@ -2283,14 +2284,15 @@ static int nghttp2_session_process_ctrl_frame(nghttp2_session *session) } else if(!session->server && stream->state == NGHTTP2_STREAM_RESERVED) { frame.headers.cat = NGHTTP2_HCAT_PUSH_RESPONSE; - r = nghttp2_session_on_push_reply_received(session, &frame, stream); + r = nghttp2_session_on_push_response_headers_received + (session, &frame, stream); } else { frame.headers.cat = NGHTTP2_HCAT_HEADERS; r = nghttp2_session_on_headers_received(session, &frame, stream); } } else { frame.headers.cat = NGHTTP2_HCAT_REQUEST; - r = nghttp2_session_on_syn_stream_received(session, &frame); + r = nghttp2_session_on_request_headers_received(session, &frame); } nghttp2_frame_headers_free(&frame.headers); nghttp2_hd_end_headers(&session->hd_inflater); diff --git a/lib/nghttp2_session.h b/lib/nghttp2_session.h index 61c48118..aa70ccd9 100644 --- a/lib/nghttp2_session.h +++ b/lib/nghttp2_session.h @@ -338,16 +338,16 @@ int nghttp2_session_close_stream_if_shut_rdwr(nghttp2_session *session, nghttp2_stream *stream); -int nghttp2_session_on_syn_stream_received(nghttp2_session *session, - nghttp2_frame *frame); +int nghttp2_session_on_request_headers_received(nghttp2_session *session, + nghttp2_frame *frame); -int nghttp2_session_on_syn_reply_received(nghttp2_session *session, - nghttp2_frame *frame, - nghttp2_stream *stream); +int nghttp2_session_on_response_headers_received(nghttp2_session *session, + nghttp2_frame *frame, + nghttp2_stream *stream); -int nghttp2_session_on_push_reply_received(nghttp2_session *session, - nghttp2_frame *frame, - nghttp2_stream *stream); +int nghttp2_session_on_push_response_headers_received(nghttp2_session *session, + nghttp2_frame *frame, + nghttp2_stream *stream); /* * Called when HEADERS is received, assuming |frame| is properly diff --git a/tests/main.c b/tests/main.c index 9d352b18..5619130e 100644 --- a/tests/main.c +++ b/tests/main.c @@ -84,14 +84,14 @@ int main(int argc, char* argv[]) test_nghttp2_session_recv_data) || !CU_add_test(pSuite, "session_add_frame", test_nghttp2_session_add_frame) || - !CU_add_test(pSuite, "session_on_syn_stream_received", - test_nghttp2_session_on_syn_stream_received) || - !CU_add_test(pSuite, "session_on_syn_reply_received", - test_nghttp2_session_on_syn_reply_received) || + !CU_add_test(pSuite, "session_on_request_headers_received", + test_nghttp2_session_on_request_headers_received) || + !CU_add_test(pSuite, "session_on_response_headers_received", + test_nghttp2_session_on_response_headers_received) || !CU_add_test(pSuite, "session_on_headers_received", test_nghttp2_session_on_headers_received) || - !CU_add_test(pSuite, "session_on_push_reply_received", - test_nghttp2_session_on_push_reply_received) || + !CU_add_test(pSuite, "session_on_push_response_headers_received", + test_nghttp2_session_on_push_response_headers_received) || !CU_add_test(pSuite, "session_on_priority_received", test_nghttp2_session_on_priority_received) || !CU_add_test(pSuite, "session_on_rst_stream_received", diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index bdc18e03..137ee2a7 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -602,7 +602,7 @@ void test_nghttp2_session_add_frame(void) nghttp2_session_del(session); } -void test_nghttp2_session_on_syn_stream_received(void) +void test_nghttp2_session_on_request_headers_received(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; @@ -626,7 +626,7 @@ void test_nghttp2_session_on_syn_stream_received(void) NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PRIORITY, stream_id, 1 << 20, nva, nvlen); - CU_ASSERT(0 == nghttp2_session_on_syn_stream_received(session, &frame)); + CU_ASSERT(0 == nghttp2_session_on_request_headers_received(session, &frame)); CU_ASSERT(1 == user_data.frame_recv_cb_called); stream = nghttp2_session_get_stream(session, stream_id); CU_ASSERT(NGHTTP2_STREAM_OPENING == stream->state); @@ -640,7 +640,7 @@ void test_nghttp2_session_on_syn_stream_received(void) nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 3, NGHTTP2_PRI_DEFAULT, nva, nvlen); user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_on_syn_stream_received(session, &frame)); + CU_ASSERT(0 == nghttp2_session_on_request_headers_received(session, &frame)); CU_ASSERT(1 == user_data.invalid_frame_recv_cb_called); CU_ASSERT(0 == (session->goaway_flags & NGHTTP2_GOAWAY_FAIL_ON_SEND)); @@ -654,7 +654,7 @@ void test_nghttp2_session_on_syn_stream_received(void) nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 3, NGHTTP2_PRI_DEFAULT, nva, nvlen); user_data.invalid_frame_recv_cb_called = 0; - CU_ASSERT(0 == nghttp2_session_on_syn_stream_received(session, &frame)); + CU_ASSERT(0 == nghttp2_session_on_request_headers_received(session, &frame)); CU_ASSERT(1 == user_data.invalid_frame_recv_cb_called); CU_ASSERT(session->goaway_flags & NGHTTP2_GOAWAY_FAIL_ON_SEND); @@ -663,7 +663,7 @@ void test_nghttp2_session_on_syn_stream_received(void) nghttp2_session_del(session); } -void test_nghttp2_session_on_syn_reply_received(void) +void test_nghttp2_session_on_response_headers_received(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; @@ -688,8 +688,8 @@ void test_nghttp2_session_on_syn_reply_received(void) nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 1, NGHTTP2_PRI_DEFAULT, nva, nvlen); - CU_ASSERT(0 == nghttp2_session_on_syn_reply_received(session, &frame, - stream)); + CU_ASSERT(0 == nghttp2_session_on_response_headers_received + (session, &frame, stream)); CU_ASSERT(1 == user_data.frame_recv_cb_called); CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state); @@ -768,7 +768,7 @@ void test_nghttp2_session_on_headers_received(void) nghttp2_session_del(session); } -void test_nghttp2_session_on_push_reply_received(void) +void test_nghttp2_session_on_push_response_headers_received(void) { nghttp2_session *session; nghttp2_session_callbacks callbacks; @@ -793,10 +793,11 @@ void test_nghttp2_session_on_push_reply_received(void) nvlen = nghttp2_nv_array_from_cstr(&nva, nv); nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 2, NGHTTP2_PRI_DEFAULT, nva, nvlen); - /* nghttp2_session_on_push_reply_received assumes stream's state is - NGHTTP2_STREAM_RESERVED and session->server is 0. */ - CU_ASSERT(0 == nghttp2_session_on_push_reply_received(session, &frame, - stream)); + /* nghttp2_session_on_push_response_headers_received assumes + stream's state is NGHTTP2_STREAM_RESERVED and session->server is + 0. */ + CU_ASSERT(0 == nghttp2_session_on_push_response_headers_received + (session, &frame, stream)); CU_ASSERT(1 == user_data.frame_recv_cb_called); CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state); CU_ASSERT(1 == session->num_incoming_streams); @@ -807,8 +808,8 @@ void test_nghttp2_session_on_push_reply_received(void) NGHTTP2_PRI_DEFAULT, NGHTTP2_STREAM_RESERVED, NULL); frame.hd.stream_id = 4; - CU_ASSERT(0 == nghttp2_session_on_push_reply_received(session, &frame, - stream)); + CU_ASSERT(0 == nghttp2_session_on_push_response_headers_received + (session, &frame, stream)); item = nghttp2_session_get_next_ob_item(session); CU_ASSERT(NGHTTP2_RST_STREAM == OB_CTRL_TYPE(item)); CU_ASSERT(NGHTTP2_REFUSED_STREAM == OB_CTRL(item)->rst_stream.error_code); @@ -2155,7 +2156,7 @@ void test_nghttp2_session_max_concurrent_streams(void) NGHTTP2_PRI_DEFAULT, nva, nvlen); session->local_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] = 1; - CU_ASSERT(0 == nghttp2_session_on_syn_stream_received(session, &frame)); + CU_ASSERT(0 == nghttp2_session_on_request_headers_received(session, &frame)); item = nghttp2_session_get_ob_pq_top(session); CU_ASSERT(NGHTTP2_RST_STREAM == OB_CTRL_TYPE(item)); @@ -2190,7 +2191,7 @@ void test_nghttp2_session_stream_close_on_headers_push(void) /* NGHTTP2_CTRL_FLAG_UNIDIRECTIONAL, */ /* 2, 1, 3, dup_nv(nv)); */ - /* CU_ASSERT(0 == nghttp2_session_on_syn_stream_received(session, &frame)); */ + /* CU_ASSERT(0 == nghttp2_session_on_request_headers_received(session, &frame)); */ /* nghttp2_frame_syn_stream_free(&frame.syn_stream); */ /* nghttp2_session_del(session); */ @@ -2547,13 +2548,13 @@ void test_nghttp2_session_on_request_recv_callback(void) nvlen = nghttp2_nv_array_from_cstr(&nva, nv); nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 1, NGHTTP2_PRI_DEFAULT, nva, nvlen); - CU_ASSERT(0 == nghttp2_session_on_syn_stream_received(session, &frame)); + CU_ASSERT(0 == nghttp2_session_on_request_headers_received(session, &frame)); CU_ASSERT(0 == user_data.stream_id); frame.hd.stream_id = 3; frame.hd.flags |= NGHTTP2_FLAG_END_STREAM; - CU_ASSERT(0 == nghttp2_session_on_syn_stream_received(session, &frame)); + CU_ASSERT(0 == nghttp2_session_on_request_headers_received(session, &frame)); CU_ASSERT(3 == user_data.stream_id); nghttp2_frame_headers_free(&frame.headers); diff --git a/tests/nghttp2_session_test.h b/tests/nghttp2_session_test.h index 97aacc1d..ed3a6843 100644 --- a/tests/nghttp2_session_test.h +++ b/tests/nghttp2_session_test.h @@ -31,10 +31,10 @@ void test_nghttp2_session_recv_invalid_frame(void); void test_nghttp2_session_recv_eof(void); void test_nghttp2_session_recv_data(void); void test_nghttp2_session_add_frame(void); -void test_nghttp2_session_on_syn_stream_received(void); -void test_nghttp2_session_on_syn_reply_received(void); +void test_nghttp2_session_on_request_headers_received(void); +void test_nghttp2_session_on_response_headers_received(void); void test_nghttp2_session_on_headers_received(void); -void test_nghttp2_session_on_push_reply_received(void); +void test_nghttp2_session_on_push_response_headers_received(void); void test_nghttp2_session_on_priority_received(void); void test_nghttp2_session_on_rst_stream_received(void); void test_nghttp2_session_on_settings_received(void);