Renamed spdylay_req_submit and spdylay_reply_submit as spdylay_submit_request and spdylay_submit_response

This commit is contained in:
Tatsuhiro Tsujikawa 2012-01-27 23:35:23 +09:00
parent 9f2f6454f3
commit 8f53343dc3
5 changed files with 36 additions and 25 deletions

View File

@ -207,7 +207,8 @@ int spdylay_session_want_read(spdylay_session *session);
int spdylay_session_want_write(spdylay_session *session);
int spdylay_req_submit(spdylay_session *session, const char *path);
int spdylay_submit_request(spdylay_session *session, uint8_t pri,
const char **nv);
/*
* Submits SYN_REPLY frame against stream |stream_id|. |nv| must
@ -218,9 +219,9 @@ int spdylay_req_submit(spdylay_session *session, const char *path);
* will be sent in subsequent DATA frames. If |data_prd| is NULL,
* SYN_REPLY will have FLAG_FIN.
*/
int spdylay_reply_submit(spdylay_session *session,
int32_t stream_id, const char **nv,
spdylay_data_provider *data_prd);
int spdylay_submit_response(spdylay_session *session,
int32_t stream_id, const char **nv,
spdylay_data_provider *data_prd);
int spdylay_submit_ping(spdylay_session *session);

View File

@ -1002,9 +1002,9 @@ int spdylay_submit_ping(spdylay_session *session)
spdylay_session_get_next_unique_id(session));
}
int spdylay_reply_submit(spdylay_session *session,
int32_t stream_id, const char **nv,
spdylay_data_provider *data_prd)
int spdylay_submit_response(spdylay_session *session,
int32_t stream_id, const char **nv,
spdylay_data_provider *data_prd)
{
int r;
spdylay_frame *frame;
@ -1049,25 +1049,35 @@ int spdylay_reply_submit(spdylay_session *session,
return 0;
}
int spdylay_req_submit(spdylay_session *session, const char *path)
int spdylay_submit_request(spdylay_session *session, uint8_t pri,
const char **nv)
{
int r;
spdylay_frame *frame;
char **nv;
char **nv_copy;
uint8_t flags = 0;
if(pri > 3) {
return SPDYLAY_ERR_INVALID_ARGUMENT;
}
frame = malloc(sizeof(spdylay_frame));
nv = malloc(9*sizeof(char*));
nv[0] = strdup("method");
nv[1] = strdup("GET");
nv[2] = strdup("scheme");
nv[3] = strdup("https");
nv[4] = strdup("url");
nv[5] = strdup(path);
nv[6] = strdup("version");
nv[7] = strdup("HTTP/1.1");
nv[8] = NULL;
if(frame == NULL) {
return SPDYLAY_ERR_NOMEM;
}
nv_copy = spdylay_frame_nv_copy(nv);
if(nv_copy == NULL) {
free(frame);
return SPDYLAY_ERR_NOMEM;
}
/* When we support POST using spdylay_data_provider, flags should be
0 if data_prd is set. */
flags |= SPDYLAY_FLAG_FIN;
spdylay_frame_syn_stream_init(&frame->syn_stream,
SPDYLAY_FLAG_FIN, 0, 0, 0, nv);
SPDYLAY_FLAG_FIN, 0, 0, pri, nv_copy);
r = spdylay_session_add_frame(session, SPDYLAY_SYN_STREAM, frame);
if(r != 0) {
spdylay_frame_syn_stream_free(&frame->syn_stream);
free(frame);
}
return r;
}

View File

@ -79,7 +79,7 @@ int main()
test_spdylay_session_send_syn_stream) ||
!CU_add_test(pSuite, "session_send_syn_reply",
test_spdylay_session_send_syn_reply) ||
!CU_add_test(pSuite, "reply_submit", test_spdylay_reply_submit) ||
!CU_add_test(pSuite, "submit_response", test_spdylay_submit_response) ||
!CU_add_test(pSuite, "session_reply_fail",
test_spdylay_session_reply_fail) ||
!CU_add_test(pSuite, "session_on_headers_received",

View File

@ -403,7 +403,7 @@ void test_spdylay_session_send_syn_reply()
spdylay_session_del(session);
}
void test_spdylay_reply_submit()
void test_spdylay_submit_response()
{
spdylay_session *session;
spdylay_session_callbacks callbacks = {
@ -427,7 +427,7 @@ void test_spdylay_reply_submit()
CU_ASSERT(0 == spdylay_session_client_new(&session, &callbacks, &ud));
spdylay_session_open_stream(session, stream_id, SPDYLAY_FLAG_NONE, 3,
SPDYLAY_STREAM_OPENING);
CU_ASSERT(0 == spdylay_reply_submit(session, stream_id, nv, &data_prd));
CU_ASSERT(0 == spdylay_submit_response(session, stream_id, nv, &data_prd));
CU_ASSERT(0 == spdylay_session_send(session));
spdylay_session_del(session);
}
@ -452,7 +452,7 @@ void test_spdylay_session_reply_fail()
my_user_data ud;
ud.data_source_length = 4*1024;
CU_ASSERT(0 == spdylay_session_client_new(&session, &callbacks, &ud));
CU_ASSERT(0 == spdylay_reply_submit(session, stream_id, nv, &data_prd));
CU_ASSERT(0 == spdylay_submit_response(session, stream_id, nv, &data_prd));
CU_ASSERT(0 == spdylay_session_send(session));
spdylay_session_del(session);
}

View File

@ -32,7 +32,7 @@ void test_spdylay_session_on_syn_stream_received();
void test_spdylay_session_on_syn_reply_received();
void test_spdylay_session_send_syn_stream();
void test_spdylay_session_send_syn_reply();
void test_spdylay_reply_submit();
void test_spdylay_submit_response();
void test_spdylay_session_reply_fail();
void test_spdylay_session_on_headers_received();
void test_spdylay_session_on_ping_received();