Support END_SEGMENT in nghttp2_submit_data()

This commit is contained in:
Tatsuhiro Tsujikawa
2014-03-06 00:19:02 +09:00
parent b60679808b
commit 54dab50015
7 changed files with 63 additions and 10 deletions

View File

@@ -2032,7 +2032,8 @@ int nghttp2_submit_headers(nghttp2_session *session, uint8_t flags,
* Submits one or more DATA frames to the stream |stream_id|. The
* data to be sent are provided by |data_prd|. If |flags| contains
* :enum:`NGHTTP2_FLAG_END_STREAM`, the last DATA frame has END_STREAM
* flag set.
* flag set. If |flags| contains :enum:`NGHTTP2_FLAG_END_SEGMENT`, the
* last DATA frame has END_SEGMENT flag set.
*
* This function does not take ownership of the |data_prd|. The
* function copies the members of the |data_prd|.

View File

@@ -186,10 +186,11 @@ void nghttp2_frame_data_init(nghttp2_data *frame, nghttp2_private_data *pdata)
{
frame->hd = pdata->hd;
frame->padlen = pdata->padlen;
/* flags may have NGHTTP2_FLAG_END_STREAM even if the sent chunk
is not the end of the stream */
/* flags may have NGHTTP2_FLAG_END_STREAM or
NGHTTP2_FLAG_END_SEGMENT even if the sent chunk is not the end of
the stream */
if(!pdata->eof) {
frame->hd.flags &= ~NGHTTP2_FLAG_END_STREAM;
frame->hd.flags &= ~(NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_SEGMENT);
}
}

View File

@@ -4532,14 +4532,17 @@ ssize_t nghttp2_session_pack_data(nghttp2_session *session,
/* Clear flags, because this may contain previous flags of previous
DATA */
frame->hd.flags &= ~(NGHTTP2_FLAG_PAD_HIGH | NGHTTP2_FLAG_PAD_LOW);
flags = 0;
frame->hd.flags &= (NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_SEGMENT);
flags = NGHTTP2_FLAG_NONE;
if(eof_flags) {
frame->eof = 1;
if(frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
flags |= NGHTTP2_FLAG_END_STREAM;
}
if(frame->hd.flags & NGHTTP2_FLAG_END_SEGMENT) {
flags |= NGHTTP2_FLAG_END_SEGMENT;
}
}
memset(&data_frame, 0, sizeof(data_frame));

View File

@@ -309,15 +309,13 @@ int nghttp2_submit_data(nghttp2_session *session, uint8_t flags,
{
int rv;
nghttp2_private_data *data_frame;
uint8_t nflags = 0;
uint8_t nflags = flags & (NGHTTP2_FLAG_END_STREAM |
NGHTTP2_FLAG_END_SEGMENT);
data_frame = malloc(sizeof(nghttp2_private_data));
if(data_frame == NULL) {
return NGHTTP2_ERR_NOMEM;
}
if(flags & NGHTTP2_FLAG_END_STREAM) {
nflags |= NGHTTP2_FLAG_END_STREAM;
}
nghttp2_frame_private_data_init(data_frame, nflags, stream_id, data_prd);
rv = nghttp2_session_add_frame(session, NGHTTP2_CAT_DATA, data_frame, NULL);
if(rv != 0) {