Commit 2a83fc75 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Add nghttp2_submit_response2

parent 679a389b
......@@ -1876,6 +1876,28 @@ int nghttp2_submit_response(nghttp2_session *session,
int32_t stream_id, const char **nv,
const nghttp2_data_provider *data_prd);
/**
* @function
*
* Just like `nghttp2_submit_response()`, but this function takes the
* |nva|, which is an array of ``nghttp2_nv`` with |nvlen| elements,
* as name/value pairs. This function is useful if name/value pairs
* are not NULL-terminated strings.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
* The |pri| is invalid; or the |nva| includes empty name or
* name which contains invalid characters.
* :enum:`NGHTTP2_ERR_NOMEM`
* Out of memory.
*/
int nghttp2_submit_response2(nghttp2_session *session,
int32_t stream_id,
const nghttp2_nv *nva, size_t nvlen,
const nghttp2_data_provider *data_prd);
/**
* @function
*
......
......@@ -326,19 +326,36 @@ int nghttp2_submit_request2(nghttp2_session *session, int32_t pri,
data_prd, stream_user_data);
}
int nghttp2_submit_response(nghttp2_session *session,
int32_t stream_id, const char **nv,
const nghttp2_data_provider *data_prd)
static uint8_t set_response_flags(const nghttp2_data_provider *data_prd)
{
uint8_t flags = NGHTTP2_FLAG_NONE;
if(data_prd == NULL || data_prd->read_callback == NULL) {
flags |= NGHTTP2_FLAG_END_STREAM;
}
return flags;
}
int nghttp2_submit_response(nghttp2_session *session,
int32_t stream_id, const char **nv,
const nghttp2_data_provider *data_prd)
{
uint8_t flags = set_response_flags(data_prd);
return nghttp2_submit_headers_shared_nv(session, flags, stream_id,
NGHTTP2_PRI_DEFAULT, nv, data_prd,
NULL);
}
int nghttp2_submit_response2(nghttp2_session *session,
int32_t stream_id,
const nghttp2_nv *nva, size_t nvlen,
const nghttp2_data_provider *data_prd)
{
uint8_t flags = set_response_flags(data_prd);
return nghttp2_submit_headers_shared_nva(session, flags, stream_id,
NGHTTP2_PRI_DEFAULT, nva, nvlen,
data_prd, NULL);
}
int nghttp2_submit_data(nghttp2_session *session, uint8_t flags,
int32_t stream_id,
const nghttp2_data_provider *data_prd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment