Added flags argument to spdylay_submit_data() and spdylay_frame_data_init().
The intention is make spdylay_submit_data() more generic, allowing trailing DATA and/or HEADERS frames.
This commit is contained in:
parent
938f51964d
commit
c1aefb3ba5
|
@ -425,14 +425,6 @@ int spdylay_submit_request(spdylay_session *session, uint8_t pri,
|
||||||
spdylay_data_provider *data_prd,
|
spdylay_data_provider *data_prd,
|
||||||
void *stream_user_data);
|
void *stream_user_data);
|
||||||
|
|
||||||
/*
|
|
||||||
* Submits DATA frame to stream |stream_id|.
|
|
||||||
*
|
|
||||||
* This function returns 0 if it succeeds, or negative error code.
|
|
||||||
*/
|
|
||||||
int spdylay_submit_data(spdylay_session *session, int32_t stream_id,
|
|
||||||
spdylay_data_provider *data_prd);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Submits SYN_REPLY frame against stream |stream_id|. |nv| must
|
* Submits SYN_REPLY frame against stream |stream_id|. |nv| must
|
||||||
* include following name/value pairs:
|
* include following name/value pairs:
|
||||||
|
@ -451,6 +443,17 @@ int spdylay_submit_response(spdylay_session *session,
|
||||||
int32_t stream_id, const char **nv,
|
int32_t stream_id, const char **nv,
|
||||||
spdylay_data_provider *data_prd);
|
spdylay_data_provider *data_prd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Submits 1 or more DATA frames to the stream |stream_id|. The data
|
||||||
|
* to be sent are provided by |data_prd|. Depending on the length of
|
||||||
|
* data, 1 or more DATA frames will be sent. If |flags| contains
|
||||||
|
* SPDYLAY_FLAG_FIN, the last DATA frame has FLAG_FIN set.
|
||||||
|
*
|
||||||
|
* This function returns 0 if it succeeds, or negative error code.
|
||||||
|
*/
|
||||||
|
int spdylay_submit_data(spdylay_session *session, int32_t stream_id,
|
||||||
|
uint8_t flags, spdylay_data_provider *data_prd);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Submits RST_STREAM frame to cancel/reset stream |stream_id| with
|
* Submits RST_STREAM frame to cancel/reset stream |stream_id| with
|
||||||
* status code |status_code|. This function returns 0 if it succeeds,
|
* status code |status_code|. This function returns 0 if it succeeds,
|
||||||
|
|
|
@ -425,10 +425,11 @@ void spdylay_frame_settings_free(spdylay_settings *frame)
|
||||||
}
|
}
|
||||||
|
|
||||||
void spdylay_frame_data_init(spdylay_data *frame, int32_t stream_id,
|
void spdylay_frame_data_init(spdylay_data *frame, int32_t stream_id,
|
||||||
spdylay_data_provider *data_prd)
|
uint8_t flags, spdylay_data_provider *data_prd)
|
||||||
{
|
{
|
||||||
memset(frame, 0, sizeof(spdylay_data));
|
memset(frame, 0, sizeof(spdylay_data));
|
||||||
frame->stream_id = stream_id;
|
frame->stream_id = stream_id;
|
||||||
|
frame->flags = flags;
|
||||||
frame->data_prd = *data_prd;
|
frame->data_prd = *data_prd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -266,7 +266,7 @@ void spdylay_frame_settings_init(spdylay_settings *frame, uint8_t flags,
|
||||||
void spdylay_frame_settings_free(spdylay_settings *frame);
|
void spdylay_frame_settings_free(spdylay_settings *frame);
|
||||||
|
|
||||||
void spdylay_frame_data_init(spdylay_data *frame, int32_t stream_id,
|
void spdylay_frame_data_init(spdylay_data *frame, int32_t stream_id,
|
||||||
spdylay_data_provider *data_prd);
|
uint8_t flags, spdylay_data_provider *data_prd);
|
||||||
|
|
||||||
void spdylay_frame_data_free(spdylay_data *frame);
|
void spdylay_frame_data_free(spdylay_data *frame);
|
||||||
|
|
||||||
|
|
|
@ -691,7 +691,7 @@ static int spdylay_session_after_frame_sent(spdylay_session *session)
|
||||||
int r;
|
int r;
|
||||||
/* spdylay_submit_data() makes a copy of aux_data->data_prd */
|
/* spdylay_submit_data() makes a copy of aux_data->data_prd */
|
||||||
r = spdylay_submit_data(session, frame->syn_stream.stream_id,
|
r = spdylay_submit_data(session, frame->syn_stream.stream_id,
|
||||||
aux_data->data_prd);
|
SPDYLAY_FLAG_FIN, aux_data->data_prd);
|
||||||
if(r != 0) {
|
if(r != 0) {
|
||||||
/* TODO If r is not FATAL, we should send RST_STREAM. */
|
/* TODO If r is not FATAL, we should send RST_STREAM. */
|
||||||
return r;
|
return r;
|
||||||
|
@ -714,7 +714,8 @@ static int spdylay_session_after_frame_sent(spdylay_session *session)
|
||||||
spdylay_data_provider *data_prd =
|
spdylay_data_provider *data_prd =
|
||||||
(spdylay_data_provider*)item->aux_data;
|
(spdylay_data_provider*)item->aux_data;
|
||||||
int r;
|
int r;
|
||||||
r = spdylay_submit_data(session, frame->syn_reply.stream_id, data_prd);
|
r = spdylay_submit_data(session, frame->syn_reply.stream_id,
|
||||||
|
SPDYLAY_FLAG_FIN, data_prd);
|
||||||
if(r != 0) {
|
if(r != 0) {
|
||||||
/* TODO If r is not FATAL, we should send RST_STREAM. */
|
/* TODO If r is not FATAL, we should send RST_STREAM. */
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -88,15 +88,20 @@ int spdylay_submit_response(spdylay_session *session,
|
||||||
}
|
}
|
||||||
|
|
||||||
int spdylay_submit_data(spdylay_session *session, int32_t stream_id,
|
int spdylay_submit_data(spdylay_session *session, int32_t stream_id,
|
||||||
|
uint8_t flags,
|
||||||
spdylay_data_provider *data_prd)
|
spdylay_data_provider *data_prd)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
spdylay_frame *frame;
|
spdylay_frame *frame;
|
||||||
|
uint8_t nflags = 0;
|
||||||
frame = malloc(sizeof(spdylay_frame));
|
frame = malloc(sizeof(spdylay_frame));
|
||||||
if(frame == NULL) {
|
if(frame == NULL) {
|
||||||
return SPDYLAY_ERR_NOMEM;
|
return SPDYLAY_ERR_NOMEM;
|
||||||
}
|
}
|
||||||
spdylay_frame_data_init(&frame->data, stream_id, data_prd);
|
if(flags & SPDYLAY_FLAG_FIN) {
|
||||||
|
nflags |= SPDYLAY_FLAG_FIN;
|
||||||
|
}
|
||||||
|
spdylay_frame_data_init(&frame->data, stream_id, nflags, data_prd);
|
||||||
r = spdylay_session_add_frame(session, SPDYLAY_DATA, frame, NULL);
|
r = spdylay_session_add_frame(session, SPDYLAY_DATA, frame, NULL);
|
||||||
if(r != 0) {
|
if(r != 0) {
|
||||||
spdylay_frame_data_free(&frame->data);
|
spdylay_frame_data_free(&frame->data);
|
||||||
|
|
Loading…
Reference in New Issue