2 nghttp2_submit_response
3 =======================
8 *#include <nghttp2/nghttp2.h>*
10 .. function:: int nghttp2_submit_response(nghttp2_session *session, int32_t stream_id, const nghttp2_nv *nva, size_t nvlen, const nghttp2_data_provider *data_prd)
13 Submits response HEADERS frame and optionally one or more DATA
14 frames against the stream *stream_id*.
16 The *nva* is an array of name/value pair :type:`nghttp2_nv` with
17 *nvlen* elements. The application is responsible to include
18 required pseudo-header fields (header field whose name starts with
19 ":") in *nva* and must place pseudo-headers before regular header
22 This function creates copies of all name/value pairs in *nva*. It
23 also lower-cases all names in *nva*. The order of elements in
26 HTTP/2 specification has requirement about header fields in the
27 response HEADERS. See the specification for more details.
29 If *data_prd* is not ``NULL``, it provides data which will be sent
30 in subsequent DATA frames. This function does not take ownership
31 of the *data_prd*. The function copies the members of the
32 *data_prd*. If *data_prd* is ``NULL``, HEADERS will have
35 This method can be used as normal HTTP response and push response.
36 When pushing a resource using this function, the *session* must be
37 configured using `nghttp2_session_server_new()` or its variants and
38 the target stream denoted by the *stream_id* must be reserved using
39 `nghttp2_submit_push_promise()`.
41 To send non-final response headers (e.g., HTTP status 101), don't
42 use this function because this function half-closes the outbound
43 stream. Instead, use `nghttp2_submit_headers()` for this purpose.
45 This function returns 0 if it succeeds, or one of the following
48 :macro:`NGHTTP2_ERR_NOMEM`
50 :macro:`NGHTTP2_ERR_INVALID_ARGUMENT`
55 Calling this function twice for the same stream ID may lead to
56 program crash. It is generally considered to a programming error
57 to commit response twice.