Rename functions related to HEADERS

This commit is contained in:
Tatsuhiro Tsujikawa 2013-07-25 21:07:38 +09:00
parent 3cc71a707e
commit 1056d8690e
5 changed files with 58 additions and 55 deletions

View File

@ -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 * Stream ID has reached the maximum value. Therefore no stream ID
* is available. * is available.
*/ */
static int nghttp2_session_predicate_syn_stream_send static int nghttp2_session_predicate_request_headers_send
(nghttp2_session *session, nghttp2_headers *frame) (nghttp2_session *session, nghttp2_headers *frame)
{ {
if(session->goaway_flags) { 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 * The state of the stream is not valid (e.g., SYN_REPLY has
* already sent). * already sent).
*/ */
static int nghttp2_session_predicate_syn_reply_send(nghttp2_session *session, static int nghttp2_session_predicate_response_headers_send
int32_t stream_id) (nghttp2_session *session, int32_t stream_id)
{ {
nghttp2_stream *stream = nghttp2_session_get_stream(session, stream_id); nghttp2_stream *stream = nghttp2_session_get_stream(session, stream_id);
int r; int r;
@ -633,8 +633,8 @@ static int nghttp2_session_predicate_syn_reply_send(nghttp2_session *session,
* NGHTTP2_ERR_STREAM_CLOSED * NGHTTP2_ERR_STREAM_CLOSED
* RST_STREAM was queued for this stream. * RST_STREAM was queued for this stream.
*/ */
static int nghttp2_session_predicate_push_reply_send(nghttp2_session *session, static int nghttp2_session_predicate_push_response_headers_send
int32_t stream_id) (nghttp2_session *session, int32_t stream_id)
{ {
nghttp2_stream *stream = nghttp2_session_get_stream(session, stream_id); nghttp2_stream *stream = nghttp2_session_get_stream(session, stream_id);
int r; int r;
@ -906,17 +906,17 @@ static ssize_t nghttp2_session_prep_frame(nghttp2_session *session,
/* initial HEADERS, which opens stream */ /* initial HEADERS, which opens stream */
int r; int r;
frame->headers.cat = NGHTTP2_HCAT_REQUEST; frame->headers.cat = NGHTTP2_HCAT_REQUEST;
r = nghttp2_session_predicate_syn_stream_send(session, r = nghttp2_session_predicate_request_headers_send(session,
&frame->headers); &frame->headers);
if(r != 0) { if(r != 0) {
return r; return r;
} }
frame->hd.stream_id = session->next_stream_id; frame->hd.stream_id = session->next_stream_id;
session->next_stream_id += 2; 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) { (session, frame->hd.stream_id) == 0) {
frame->headers.cat = NGHTTP2_HCAT_PUSH_RESPONSE; 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) { (session, frame->hd.stream_id) == 0) {
frame->headers.cat = NGHTTP2_HCAT_RESPONSE; frame->headers.cat = NGHTTP2_HCAT_RESPONSE;
} else { } else {
@ -1654,8 +1654,8 @@ static int nghttp2_session_handle_invalid_connection
return nghttp2_session_fail_session(session, error_code); return nghttp2_session_fail_session(session, error_code);
} }
int nghttp2_session_on_syn_stream_received(nghttp2_session *session, int nghttp2_session_on_request_headers_received(nghttp2_session *session,
nghttp2_frame *frame) nghttp2_frame *frame)
{ {
int r = 0; int r = 0;
nghttp2_error_code error_code = NGHTTP2_NO_ERROR; nghttp2_error_code error_code = NGHTTP2_NO_ERROR;
@ -1702,9 +1702,9 @@ int nghttp2_session_on_syn_stream_received(nghttp2_session *session,
return r; return r;
} }
int nghttp2_session_on_syn_reply_received(nghttp2_session *session, int nghttp2_session_on_response_headers_received(nghttp2_session *session,
nghttp2_frame *frame, nghttp2_frame *frame,
nghttp2_stream *stream) nghttp2_stream *stream)
{ {
/* This function is only called if stream->state == /* This function is only called if stream->state ==
NGHTTP2_STREAM_OPENING and stream_id is local side initiated. */ 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; return 0;
} }
int nghttp2_session_on_push_reply_received(nghttp2_session *session, int nghttp2_session_on_push_response_headers_received(nghttp2_session *session,
nghttp2_frame *frame, nghttp2_frame *frame,
nghttp2_stream *stream) nghttp2_stream *stream)
{ {
int rv = 0; int rv = 0;
assert(!session->server && stream->state == NGHTTP2_STREAM_RESERVED); 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(nghttp2_session_is_my_stream_id(session, frame.hd.stream_id)) {
if(stream->state == NGHTTP2_STREAM_OPENING) { if(stream->state == NGHTTP2_STREAM_OPENING) {
frame.headers.cat = NGHTTP2_HCAT_RESPONSE; 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 { } else {
frame.headers.cat = NGHTTP2_HCAT_HEADERS; frame.headers.cat = NGHTTP2_HCAT_HEADERS;
r = nghttp2_session_on_headers_received(session, &frame, stream); 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 && } else if(!session->server &&
stream->state == NGHTTP2_STREAM_RESERVED) { stream->state == NGHTTP2_STREAM_RESERVED) {
frame.headers.cat = NGHTTP2_HCAT_PUSH_RESPONSE; 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 { } else {
frame.headers.cat = NGHTTP2_HCAT_HEADERS; frame.headers.cat = NGHTTP2_HCAT_HEADERS;
r = nghttp2_session_on_headers_received(session, &frame, stream); r = nghttp2_session_on_headers_received(session, &frame, stream);
} }
} else { } else {
frame.headers.cat = NGHTTP2_HCAT_REQUEST; 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_frame_headers_free(&frame.headers);
nghttp2_hd_end_headers(&session->hd_inflater); nghttp2_hd_end_headers(&session->hd_inflater);

View File

@ -338,16 +338,16 @@ int nghttp2_session_close_stream_if_shut_rdwr(nghttp2_session *session,
nghttp2_stream *stream); nghttp2_stream *stream);
int nghttp2_session_on_syn_stream_received(nghttp2_session *session, int nghttp2_session_on_request_headers_received(nghttp2_session *session,
nghttp2_frame *frame); nghttp2_frame *frame);
int nghttp2_session_on_syn_reply_received(nghttp2_session *session, int nghttp2_session_on_response_headers_received(nghttp2_session *session,
nghttp2_frame *frame, nghttp2_frame *frame,
nghttp2_stream *stream); nghttp2_stream *stream);
int nghttp2_session_on_push_reply_received(nghttp2_session *session, int nghttp2_session_on_push_response_headers_received(nghttp2_session *session,
nghttp2_frame *frame, nghttp2_frame *frame,
nghttp2_stream *stream); nghttp2_stream *stream);
/* /*
* Called when HEADERS is received, assuming |frame| is properly * Called when HEADERS is received, assuming |frame| is properly

View File

@ -84,14 +84,14 @@ int main(int argc, char* argv[])
test_nghttp2_session_recv_data) || test_nghttp2_session_recv_data) ||
!CU_add_test(pSuite, "session_add_frame", !CU_add_test(pSuite, "session_add_frame",
test_nghttp2_session_add_frame) || test_nghttp2_session_add_frame) ||
!CU_add_test(pSuite, "session_on_syn_stream_received", !CU_add_test(pSuite, "session_on_request_headers_received",
test_nghttp2_session_on_syn_stream_received) || test_nghttp2_session_on_request_headers_received) ||
!CU_add_test(pSuite, "session_on_syn_reply_received", !CU_add_test(pSuite, "session_on_response_headers_received",
test_nghttp2_session_on_syn_reply_received) || test_nghttp2_session_on_response_headers_received) ||
!CU_add_test(pSuite, "session_on_headers_received", !CU_add_test(pSuite, "session_on_headers_received",
test_nghttp2_session_on_headers_received) || test_nghttp2_session_on_headers_received) ||
!CU_add_test(pSuite, "session_on_push_reply_received", !CU_add_test(pSuite, "session_on_push_response_headers_received",
test_nghttp2_session_on_push_reply_received) || test_nghttp2_session_on_push_response_headers_received) ||
!CU_add_test(pSuite, "session_on_priority_received", !CU_add_test(pSuite, "session_on_priority_received",
test_nghttp2_session_on_priority_received) || test_nghttp2_session_on_priority_received) ||
!CU_add_test(pSuite, "session_on_rst_stream_received", !CU_add_test(pSuite, "session_on_rst_stream_received",

View File

@ -602,7 +602,7 @@ void test_nghttp2_session_add_frame(void)
nghttp2_session_del(session); 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 *session;
nghttp2_session_callbacks callbacks; nghttp2_session_callbacks callbacks;
@ -626,7 +626,7 @@ void test_nghttp2_session_on_syn_stream_received(void)
NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PRIORITY, NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PRIORITY,
stream_id, 1 << 20, nva, nvlen); 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); CU_ASSERT(1 == user_data.frame_recv_cb_called);
stream = nghttp2_session_get_stream(session, stream_id); stream = nghttp2_session_get_stream(session, stream_id);
CU_ASSERT(NGHTTP2_STREAM_OPENING == stream->state); 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, nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS,
3, NGHTTP2_PRI_DEFAULT, nva, nvlen); 3, NGHTTP2_PRI_DEFAULT, nva, nvlen);
user_data.invalid_frame_recv_cb_called = 0; 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(1 == user_data.invalid_frame_recv_cb_called);
CU_ASSERT(0 == (session->goaway_flags & NGHTTP2_GOAWAY_FAIL_ON_SEND)); 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, nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS,
3, NGHTTP2_PRI_DEFAULT, nva, nvlen); 3, NGHTTP2_PRI_DEFAULT, nva, nvlen);
user_data.invalid_frame_recv_cb_called = 0; 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(1 == user_data.invalid_frame_recv_cb_called);
CU_ASSERT(session->goaway_flags & NGHTTP2_GOAWAY_FAIL_ON_SEND); 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); 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 *session;
nghttp2_session_callbacks callbacks; 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_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 1,
NGHTTP2_PRI_DEFAULT, nva, nvlen); NGHTTP2_PRI_DEFAULT, nva, nvlen);
CU_ASSERT(0 == nghttp2_session_on_syn_reply_received(session, &frame, CU_ASSERT(0 == nghttp2_session_on_response_headers_received
stream)); (session, &frame, stream));
CU_ASSERT(1 == user_data.frame_recv_cb_called); CU_ASSERT(1 == user_data.frame_recv_cb_called);
CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state); CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state);
@ -768,7 +768,7 @@ void test_nghttp2_session_on_headers_received(void)
nghttp2_session_del(session); 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 *session;
nghttp2_session_callbacks callbacks; 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); nvlen = nghttp2_nv_array_from_cstr(&nva, nv);
nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 2, nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 2,
NGHTTP2_PRI_DEFAULT, nva, nvlen); NGHTTP2_PRI_DEFAULT, nva, nvlen);
/* nghttp2_session_on_push_reply_received assumes stream's state is /* nghttp2_session_on_push_response_headers_received assumes
NGHTTP2_STREAM_RESERVED and session->server is 0. */ stream's state is NGHTTP2_STREAM_RESERVED and session->server is
CU_ASSERT(0 == nghttp2_session_on_push_reply_received(session, &frame, 0. */
stream)); CU_ASSERT(0 == nghttp2_session_on_push_response_headers_received
(session, &frame, stream));
CU_ASSERT(1 == user_data.frame_recv_cb_called); CU_ASSERT(1 == user_data.frame_recv_cb_called);
CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state); CU_ASSERT(NGHTTP2_STREAM_OPENED == stream->state);
CU_ASSERT(1 == session->num_incoming_streams); CU_ASSERT(1 == session->num_incoming_streams);
@ -807,8 +808,8 @@ void test_nghttp2_session_on_push_reply_received(void)
NGHTTP2_PRI_DEFAULT, NGHTTP2_PRI_DEFAULT,
NGHTTP2_STREAM_RESERVED, NULL); NGHTTP2_STREAM_RESERVED, NULL);
frame.hd.stream_id = 4; frame.hd.stream_id = 4;
CU_ASSERT(0 == nghttp2_session_on_push_reply_received(session, &frame, CU_ASSERT(0 == nghttp2_session_on_push_response_headers_received
stream)); (session, &frame, stream));
item = nghttp2_session_get_next_ob_item(session); item = nghttp2_session_get_next_ob_item(session);
CU_ASSERT(NGHTTP2_RST_STREAM == OB_CTRL_TYPE(item)); CU_ASSERT(NGHTTP2_RST_STREAM == OB_CTRL_TYPE(item));
CU_ASSERT(NGHTTP2_REFUSED_STREAM == OB_CTRL(item)->rst_stream.error_code); 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); NGHTTP2_PRI_DEFAULT, nva, nvlen);
session->local_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] = 1; 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); item = nghttp2_session_get_ob_pq_top(session);
CU_ASSERT(NGHTTP2_RST_STREAM == OB_CTRL_TYPE(item)); 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, */ /* NGHTTP2_CTRL_FLAG_UNIDIRECTIONAL, */
/* 2, 1, 3, dup_nv(nv)); */ /* 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_frame_syn_stream_free(&frame.syn_stream); */
/* nghttp2_session_del(session); */ /* 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); nvlen = nghttp2_nv_array_from_cstr(&nva, nv);
nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS,
1, NGHTTP2_PRI_DEFAULT, nva, nvlen); 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); CU_ASSERT(0 == user_data.stream_id);
frame.hd.stream_id = 3; frame.hd.stream_id = 3;
frame.hd.flags |= NGHTTP2_FLAG_END_STREAM; 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); CU_ASSERT(3 == user_data.stream_id);
nghttp2_frame_headers_free(&frame.headers); nghttp2_frame_headers_free(&frame.headers);

View File

@ -31,10 +31,10 @@ void test_nghttp2_session_recv_invalid_frame(void);
void test_nghttp2_session_recv_eof(void); void test_nghttp2_session_recv_eof(void);
void test_nghttp2_session_recv_data(void); void test_nghttp2_session_recv_data(void);
void test_nghttp2_session_add_frame(void); void test_nghttp2_session_add_frame(void);
void test_nghttp2_session_on_syn_stream_received(void); void test_nghttp2_session_on_request_headers_received(void);
void test_nghttp2_session_on_syn_reply_received(void); void test_nghttp2_session_on_response_headers_received(void);
void test_nghttp2_session_on_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_priority_received(void);
void test_nghttp2_session_on_rst_stream_received(void); void test_nghttp2_session_on_rst_stream_received(void);
void test_nghttp2_session_on_settings_received(void); void test_nghttp2_session_on_settings_received(void);