Update doc
This commit is contained in:
parent
4368c03d80
commit
9b03a75ddd
491
apiref.html
491
apiref.html
|
@ -1088,7 +1088,7 @@ int32_t <tt class="descname">stream_id</tt><a class="headerlink" href="#c.nghttp
|
|||
<dl class="member">
|
||||
<dt id="c.nghttp2_frame_hd.type">
|
||||
uint8_t <tt class="descname">type</tt><a class="headerlink" href="#c.nghttp2_frame_hd.type" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The type of this frame. See <a class="reference internal" href="#c.nghttp2_frame" title="nghttp2_frame"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_frame()</span></tt></a>.</p>
|
||||
<dd><p>The type of this frame. See <a class="reference internal" href="#c.nghttp2_frame_type" title="nghttp2_frame_type"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_frame_type()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="member">
|
||||
|
@ -1274,7 +1274,7 @@ size_t <tt class="descname">nvlen</tt><a class="headerlink" href="#c.nghttp2_hea
|
|||
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_rst_stream.error_code">
|
||||
<a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code">nghttp2_error_code</a> <tt class="descname">error_code</tt><a class="headerlink" href="#c.nghttp2_rst_stream.error_code" title="Permalink to this definition">¶</a></dt>
|
||||
uint32_t <tt class="descname">error_code</tt><a class="headerlink" href="#c.nghttp2_rst_stream.error_code" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The error code. See <a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_error_code</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
|
@ -1395,7 +1395,7 @@ int32_t <tt class="descname">last_stream_id</tt><a class="headerlink" href="#c.n
|
|||
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_goaway.error_code">
|
||||
<a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code">nghttp2_error_code</a> <tt class="descname">error_code</tt><a class="headerlink" href="#c.nghttp2_goaway.error_code" title="Permalink to this definition">¶</a></dt>
|
||||
uint32_t <tt class="descname">error_code</tt><a class="headerlink" href="#c.nghttp2_goaway.error_code" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The error code. See <a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_error_code</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
|
@ -1596,6 +1596,8 @@ it must return <a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILU
|
|||
<a class="reference internal" href="#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a> to send data to the remote endpoint. If
|
||||
the application uses solely <a class="reference internal" href="#c.nghttp2_session_mem_send" title="nghttp2_session_mem_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_mem_send()</span></tt></a> instead,
|
||||
this callback function is unnecessary.</p>
|
||||
<p>To set this callback to <a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session_callbacks</span></tt></a>, use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_set_send_callback" title="nghttp2_session_callbacks_set_send_callback"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_set_send_callback()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
|
@ -1617,6 +1619,8 @@ Returning 0 is treated as <a class="reference internal" href="#c.NGHTTP2_ERR_WOU
|
|||
<a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> to receive data from the remote endpoint.
|
||||
If the application uses solely <a class="reference internal" href="#c.nghttp2_session_mem_recv" title="nghttp2_session_mem_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_mem_recv()</span></tt></a>
|
||||
instead, this callback function is unnecessary.</p>
|
||||
<p>To set this callback to <a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session_callbacks</span></tt></a>, use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_set_recv_callback" title="nghttp2_session_callbacks_set_recv_callback"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_set_recv_callback()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
|
@ -1638,22 +1642,27 @@ check that stream is still alive using its own stream management or
|
|||
<p>Only HEADERS and DATA frame can signal the end of incoming data.
|
||||
If <tt class="docutils literal"><span class="pre">frame->hd.flags</span> <span class="pre">&</span> <span class="pre">NGHTTP2_FLAG_END_STREAM</span></tt> is nonzero, the
|
||||
<em>frame</em> is the last frame from the remote peer in this stream.</p>
|
||||
<p>This callback won’t be called for CONTINUATION frames.
|
||||
HEADERS/PUSH_PROMISE + CONTINUATIONs are treated as single frame.</p>
|
||||
<p>The implementation of this function must return 0 if it succeeds.
|
||||
If nonzero value is returned, it is treated as fatal error and
|
||||
<a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> and <a class="reference internal" href="#c.nghttp2_session_mem_recv" title="nghttp2_session_mem_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_mem_recv()</span></tt></a> functions
|
||||
immediately return <a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a>.</p>
|
||||
<p>To set this callback to <a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session_callbacks</span></tt></a>, use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_set_on_frame_recv_callback" title="nghttp2_session_callbacks_set_on_frame_recv_callback"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_set_on_frame_recv_callback()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
<dt id="c.nghttp2_on_invalid_frame_recv_callback">
|
||||
typedef int <tt class="descname">(*nghttp2_on_invalid_frame_recv_callback)</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, const <a class="reference internal" href="#c.nghttp2_frame" title="nghttp2_frame">nghttp2_frame</a><em> *frame</em>, <a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code">nghttp2_error_code</a><em> error_code</em>, void<em> *user_data</em><big>)</big><a class="headerlink" href="#c.nghttp2_on_invalid_frame_recv_callback" title="Permalink to this definition">¶</a></dt>
|
||||
typedef int <tt class="descname">(*nghttp2_on_invalid_frame_recv_callback)</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, const <a class="reference internal" href="#c.nghttp2_frame" title="nghttp2_frame">nghttp2_frame</a><em> *frame</em>, uint32_t<em> error_code</em>, void<em> *user_data</em><big>)</big><a class="headerlink" href="#c.nghttp2_on_invalid_frame_recv_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked by <a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> when an
|
||||
invalid non-DATA frame is received. The <em>error_code</em> is one of the
|
||||
<a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code"><tt class="xref c c-macro docutils literal"><span class="pre">nghttp2_error_code</span></tt></a> and indicates the error. When this
|
||||
callback function is invoked, the library automatically submits
|
||||
either RST_STREAM or GOAWAY frame. The <em>user_data</em> pointer is the
|
||||
third argument passed in to the call to
|
||||
<a class="reference internal" href="#c.nghttp2_session_client_new" title="nghttp2_session_client_new"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_client_new()</span></tt></a> or <a class="reference internal" href="#c.nghttp2_session_server_new" title="nghttp2_session_server_new"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_server_new()</span></tt></a>.</p>
|
||||
invalid non-DATA frame is received. The <em>error_code</em> indicates the
|
||||
error. It is usually one of the <a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code"><tt class="xref c c-macro docutils literal"><span class="pre">nghttp2_error_code</span></tt></a> but
|
||||
that is not guaranteed. When this callback function is invoked,
|
||||
the library automatically submits either RST_STREAM or GOAWAY
|
||||
frame. The <em>user_data</em> pointer is the third argument passed in to
|
||||
the call to <a class="reference internal" href="#c.nghttp2_session_client_new" title="nghttp2_session_client_new"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_client_new()</span></tt></a> or
|
||||
<a class="reference internal" href="#c.nghttp2_session_server_new" title="nghttp2_session_server_new"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_server_new()</span></tt></a>.</p>
|
||||
<p>If frame is HEADERS or PUSH_PROMISE, the <tt class="docutils literal"><span class="pre">nva</span></tt> and <tt class="docutils literal"><span class="pre">nvlen</span></tt>
|
||||
member of their data structure are always <tt class="docutils literal"><span class="pre">NULL</span></tt> and 0
|
||||
respectively.</p>
|
||||
|
@ -1661,6 +1670,8 @@ respectively.</p>
|
|||
If nonzero is returned, it is treated as fatal error and
|
||||
<a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> and <a class="reference internal" href="#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a> functions
|
||||
immediately return <a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a>.</p>
|
||||
<p>To set this callback to <a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session_callbacks</span></tt></a>, use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_set_on_invalid_frame_recv_callback" title="nghttp2_session_callbacks_set_on_invalid_frame_recv_callback"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_set_on_invalid_frame_recv_callback()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
|
@ -1687,6 +1698,8 @@ region included in the input bytes.</p>
|
|||
If nonzero is returned, it is treated as fatal error and
|
||||
<a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> and <a class="reference internal" href="#c.nghttp2_session_mem_recv" title="nghttp2_session_mem_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_mem_recv()</span></tt></a> functions
|
||||
immediately return <a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a>.</p>
|
||||
<p>To set this callback to <a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session_callbacks</span></tt></a>, use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_set_on_data_chunk_recv_callback" title="nghttp2_session_callbacks_set_on_data_chunk_recv_callback"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_set_on_data_chunk_recv_callback()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
|
@ -1700,6 +1713,8 @@ the call to <a class="reference internal" href="#c.nghttp2_session_client_new" t
|
|||
If nonzero is returned, it is treated as fatal error and
|
||||
<a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> and <a class="reference internal" href="#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a> functions
|
||||
immediately return <a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a>.</p>
|
||||
<p>To set this callback to <a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session_callbacks</span></tt></a>, use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_set_before_frame_send_callback" title="nghttp2_session_callbacks_set_before_frame_send_callback"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_set_before_frame_send_callback()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
|
@ -1712,6 +1727,8 @@ typedef int <tt class="descname">(*nghttp2_on_frame_send_callback)</tt><big>(</b
|
|||
If nonzero is returned, it is treated as fatal error and
|
||||
<a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> and <a class="reference internal" href="#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a> functions
|
||||
immediately return <a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a>.</p>
|
||||
<p>To set this callback to <a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session_callbacks</span></tt></a>, use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_set_on_frame_send_callback" title="nghttp2_session_callbacks_set_on_frame_send_callback"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_set_on_frame_send_callback()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
|
@ -1727,41 +1744,28 @@ argument passed in to the call to <a class="reference internal" href="#c.nghttp2
|
|||
If nonzero is returned, it is treated as fatal error and
|
||||
<a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> and <a class="reference internal" href="#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a> functions
|
||||
immediately return <a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a>.</p>
|
||||
<p>To set this callback to <a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session_callbacks</span></tt></a>, use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_set_on_frame_not_send_callback" title="nghttp2_session_callbacks_set_on_frame_not_send_callback"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_set_on_frame_not_send_callback()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
<dt id="c.nghttp2_on_stream_close_callback">
|
||||
typedef int <tt class="descname">(*nghttp2_on_stream_close_callback)</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, int32_t<em> stream_id</em>, <a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code">nghttp2_error_code</a><em> error_code</em>, void<em> *user_data</em><big>)</big><a class="headerlink" href="#c.nghttp2_on_stream_close_callback" title="Permalink to this definition">¶</a></dt>
|
||||
typedef int <tt class="descname">(*nghttp2_on_stream_close_callback)</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, int32_t<em> stream_id</em>, uint32_t<em> error_code</em>, void<em> *user_data</em><big>)</big><a class="headerlink" href="#c.nghttp2_on_stream_close_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked when the stream <em>stream_id</em> is closed.
|
||||
The reason of closure is indicated by the <em>error_code</em>. The
|
||||
stream_user_data, which was specified in <a class="reference internal" href="#c.nghttp2_submit_request" title="nghttp2_submit_request"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_submit_request()</span></tt></a>
|
||||
or <a class="reference internal" href="#c.nghttp2_submit_headers" title="nghttp2_submit_headers"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_submit_headers()</span></tt></a>, is still available in this function.
|
||||
The <em>user_data</em> pointer is the third argument passed in to the call
|
||||
to <a class="reference internal" href="#c.nghttp2_session_client_new" title="nghttp2_session_client_new"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_client_new()</span></tt></a> or
|
||||
<em>error_code</em> is usually one of <a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code"><tt class="xref c c-macro docutils literal"><span class="pre">nghttp2_error_code</span></tt></a>, but that
|
||||
is not guaranteed. The stream_user_data, which was specified in
|
||||
<a class="reference internal" href="#c.nghttp2_submit_request" title="nghttp2_submit_request"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_submit_request()</span></tt></a> or <a class="reference internal" href="#c.nghttp2_submit_headers" title="nghttp2_submit_headers"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_submit_headers()</span></tt></a>, is still
|
||||
available in this function. The <em>user_data</em> pointer is the third
|
||||
argument passed in to the call to <a class="reference internal" href="#c.nghttp2_session_client_new" title="nghttp2_session_client_new"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_client_new()</span></tt></a> or
|
||||
<a class="reference internal" href="#c.nghttp2_session_server_new" title="nghttp2_session_server_new"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_server_new()</span></tt></a>.</p>
|
||||
<p>This function is also called for a stream in reserved state.</p>
|
||||
<p>The implementation of this function must return 0 if it succeeds.
|
||||
If nonzero is returned, it is treated as fatal error and
|
||||
<a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> and <a class="reference internal" href="#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a> functions
|
||||
immediately return <a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
<dt id="c.nghttp2_on_unknown_frame_recv_callback">
|
||||
typedef int <tt class="descname">(*nghttp2_on_unknown_frame_recv_callback)</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, const uint8_t<em> *head</em>, size_t<em> headlen</em>, const uint8_t<em> *payload</em>, size_t<em> payloadlen</em>, void<em> *user_data</em><big>)</big><a class="headerlink" href="#c.nghttp2_on_unknown_frame_recv_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked when the received frame type is unknown.
|
||||
The <em>head</em> is the pointer to the header of the received frame. The
|
||||
<em>headlen</em> is the length of the <em>head</em>. According to the spec, the
|
||||
<em>headlen</em> is always 8. In other words, the <em>head</em> is the first 8
|
||||
bytes of the received frame. The <em>payload</em> is the pointer to the
|
||||
data portion of the received frame. The <em>payloadlen</em> is the length
|
||||
of the <em>payload</em>. This is the data after the length field. The
|
||||
<em>user_data</em> pointer is the third argument passed in to the call to
|
||||
<a class="reference internal" href="#c.nghttp2_session_client_new" title="nghttp2_session_client_new"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_client_new()</span></tt></a> or <a class="reference internal" href="#c.nghttp2_session_server_new" title="nghttp2_session_server_new"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_server_new()</span></tt></a>.</p>
|
||||
<p>The implementation of this function must return 0 if it succeeds.
|
||||
If nonzero is returned, it is treated as fatal error and
|
||||
<a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> and <a class="reference internal" href="#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a> functions
|
||||
immediately return <a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a>.</p>
|
||||
<p>To set this callback to <a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session_callbacks</span></tt></a>, use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_set_on_stream_close_callback" title="nghttp2_session_callbacks_set_on_stream_close_callback"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_set_on_stream_close_callback()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
|
@ -1782,6 +1786,8 @@ if <a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="N
|
|||
<a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a> is returned,
|
||||
<a class="reference internal" href="#c.nghttp2_session_mem_recv" title="nghttp2_session_mem_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_mem_recv()</span></tt></a> function will immediately return
|
||||
<a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a>.</p>
|
||||
<p>To set this callback to <a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session_callbacks</span></tt></a>, use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_set_on_begin_headers_callback" title="nghttp2_session_callbacks_set_on_begin_headers_callback"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_set_on_begin_headers_callback()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
|
@ -1834,6 +1840,8 @@ the other nonzero value is returned, it is treated as
|
|||
<a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a> is returned,
|
||||
<a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> and <a class="reference internal" href="#c.nghttp2_session_mem_recv" title="nghttp2_session_mem_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_mem_recv()</span></tt></a> functions
|
||||
immediately return <a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a>.</p>
|
||||
<p>To set this callback to <a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session_callbacks</span></tt></a>, use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_set_on_header_callback" title="nghttp2_session_callbacks_set_on_header_callback"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_set_on_header_callback()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
|
@ -1849,105 +1857,57 @@ inclusive. Choosing number not in this range will be treated as
|
|||
<a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a> will make
|
||||
<a class="reference internal" href="#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a> function immediately return
|
||||
<a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a>.</p>
|
||||
<p>To set this callback to <a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session_callbacks</span></tt></a>, use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_set_select_padding_callback" title="nghttp2_session_callbacks_set_select_padding_callback"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_set_select_padding_callback()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
<dt id="c.nghttp2_data_source_read_length_callback">
|
||||
typedef ssize_t <tt class="descname">(*nghttp2_data_source_read_length_callback)</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, uint8_t<em> frame_type</em>, int32_t<em> stream_id</em>, int32_t<em> session_remote_window_size</em>, int32_t<em> stream_remote_window_size</em>, uint32_t<em> remote_max_frame_size</em>, void<em> *user_data</em><big>)</big><a class="headerlink" href="#c.nghttp2_data_source_read_length_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked when library wants to get max length of
|
||||
data to send data to the remote peer. The implementation of this
|
||||
function should return a value in the following range. [1,
|
||||
min(<em>session_remote_window_size</em>, <em>stream_remote_window_size</em>,
|
||||
<em>remote_max_frame_size</em>)]. If a value greater than this range is
|
||||
returned than the max allow value will be used. Returning a value
|
||||
smaller than this range is treated as
|
||||
<a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a>. The <em>frame_type</em> is provided
|
||||
for future extensibility and identifies the type of frame (see
|
||||
<a class="reference internal" href="#c.nghttp2_frame_type" title="nghttp2_frame_type"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_frame_type</span></tt></a>) for which to get the length for.
|
||||
Currently supported frame types are: <a class="reference internal" href="#c.NGHTTP2_DATA" title="NGHTTP2_DATA"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_DATA</span></tt></a>.</p>
|
||||
<p>This callback can be used to control the length in bytes for which
|
||||
<a class="reference internal" href="#c.nghttp2_data_source_read_callback" title="nghttp2_data_source_read_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_data_source_read_callback</span></tt></a> is allowed to send to the
|
||||
remote endpoint. This callback is optional. Returning
|
||||
<a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a> will signal the entire session
|
||||
failure.</p>
|
||||
<p>To set this callback to <a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session_callbacks</span></tt></a>, use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_set_data_source_read_length_callback" title="nghttp2_session_callbacks_set_data_source_read_length_callback"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_set_data_source_read_length_callback()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
<dt id="c.nghttp2_on_begin_frame_callback">
|
||||
typedef int <tt class="descname">(*nghttp2_on_begin_frame_callback)</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, const <a class="reference internal" href="#c.nghttp2_frame_hd" title="nghttp2_frame_hd">nghttp2_frame_hd</a><em> *hd</em>, void<em> *user_data</em><big>)</big><a class="headerlink" href="#c.nghttp2_on_begin_frame_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked when a frame header is received. The
|
||||
<em>hd</em> points to received frame header.</p>
|
||||
<p>Unlike <a class="reference internal" href="#c.nghttp2_on_frame_recv_callback" title="nghttp2_on_frame_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_frame_recv_callback</span></tt></a>, this callback will
|
||||
also be called when frame header of CONTINUATION frame is received.</p>
|
||||
<p>If both <a class="reference internal" href="#c.nghttp2_on_begin_frame_callback" title="nghttp2_on_begin_frame_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_begin_frame_callback</span></tt></a> and
|
||||
<a class="reference internal" href="#c.nghttp2_on_begin_headers_callback" title="nghttp2_on_begin_headers_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_begin_headers_callback</span></tt></a> are set and HEADERS or
|
||||
PUSH_PROMISE is received, <a class="reference internal" href="#c.nghttp2_on_begin_frame_callback" title="nghttp2_on_begin_frame_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_begin_frame_callback</span></tt></a>
|
||||
will be called first.</p>
|
||||
<p>The implementation of this function must return 0 if it succeeds.
|
||||
If nonzero value is returned, it is treated as fatal error and
|
||||
<a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> and <a class="reference internal" href="#c.nghttp2_session_mem_recv" title="nghttp2_session_mem_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_mem_recv()</span></tt></a> functions
|
||||
immediately return <a class="reference internal" href="#c.NGHTTP2_ERR_CALLBACK_FAILURE" title="NGHTTP2_ERR_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_CALLBACK_FAILURE</span></tt></a>.</p>
|
||||
<p>To set this callback to <a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session_callbacks</span></tt></a>, use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_set_on_begin_frame_callback" title="nghttp2_session_callbacks_set_on_begin_frame_callback"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_set_on_begin_frame_callback()</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
<dt id="c.nghttp2_session_callbacks">
|
||||
<tt class="descname">nghttp2_session_callbacks</tt><a class="headerlink" href="#c.nghttp2_session_callbacks" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback functions.</p>
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_session_callbacks.send_callback">
|
||||
<a class="reference internal" href="#c.nghttp2_send_callback" title="nghttp2_send_callback">nghttp2_send_callback</a> <tt class="descname">send_callback</tt><a class="headerlink" href="#c.nghttp2_session_callbacks.send_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked when the <em>session</em> wants to send data
|
||||
to the remote peer. This callback is not necessary if the
|
||||
application uses solely <a class="reference internal" href="#c.nghttp2_session_mem_send" title="nghttp2_session_mem_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_mem_send()</span></tt></a> to serialize
|
||||
data to transmit.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_session_callbacks.recv_callback">
|
||||
<a class="reference internal" href="#c.nghttp2_recv_callback" title="nghttp2_recv_callback">nghttp2_recv_callback</a> <tt class="descname">recv_callback</tt><a class="headerlink" href="#c.nghttp2_session_callbacks.recv_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked when the <em>session</em> wants to receive
|
||||
data from the remote peer. This callback is not necessary if the
|
||||
application uses solely <a class="reference internal" href="#c.nghttp2_session_mem_recv" title="nghttp2_session_mem_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_mem_recv()</span></tt></a> to process
|
||||
received data.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_session_callbacks.on_frame_recv_callback">
|
||||
<a class="reference internal" href="#c.nghttp2_on_frame_recv_callback" title="nghttp2_on_frame_recv_callback">nghttp2_on_frame_recv_callback</a> <tt class="descname">on_frame_recv_callback</tt><a class="headerlink" href="#c.nghttp2_session_callbacks.on_frame_recv_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked by <a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> when a
|
||||
frame is received.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_session_callbacks.on_invalid_frame_recv_callback">
|
||||
<a class="reference internal" href="#c.nghttp2_on_invalid_frame_recv_callback" title="nghttp2_on_invalid_frame_recv_callback">nghttp2_on_invalid_frame_recv_callback</a> <tt class="descname">on_invalid_frame_recv_callback</tt><a class="headerlink" href="#c.nghttp2_session_callbacks.on_invalid_frame_recv_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked by <a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> when an
|
||||
invalid non-DATA frame is received.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_session_callbacks.on_data_chunk_recv_callback">
|
||||
<a class="reference internal" href="#c.nghttp2_on_data_chunk_recv_callback" title="nghttp2_on_data_chunk_recv_callback">nghttp2_on_data_chunk_recv_callback</a> <tt class="descname">on_data_chunk_recv_callback</tt><a class="headerlink" href="#c.nghttp2_session_callbacks.on_data_chunk_recv_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked when a chunk of data in DATA frame is
|
||||
received.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_session_callbacks.before_frame_send_callback">
|
||||
<a class="reference internal" href="#c.nghttp2_before_frame_send_callback" title="nghttp2_before_frame_send_callback">nghttp2_before_frame_send_callback</a> <tt class="descname">before_frame_send_callback</tt><a class="headerlink" href="#c.nghttp2_session_callbacks.before_frame_send_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked before a non-DATA frame is sent.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_session_callbacks.on_frame_send_callback">
|
||||
<a class="reference internal" href="#c.nghttp2_on_frame_send_callback" title="nghttp2_on_frame_send_callback">nghttp2_on_frame_send_callback</a> <tt class="descname">on_frame_send_callback</tt><a class="headerlink" href="#c.nghttp2_session_callbacks.on_frame_send_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked after a frame is sent.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_session_callbacks.on_frame_not_send_callback">
|
||||
<a class="reference internal" href="#c.nghttp2_on_frame_not_send_callback" title="nghttp2_on_frame_not_send_callback">nghttp2_on_frame_not_send_callback</a> <tt class="descname">on_frame_not_send_callback</tt><a class="headerlink" href="#c.nghttp2_session_callbacks.on_frame_not_send_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The callback function invoked when a non-DATA frame is not sent
|
||||
because of an error.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_session_callbacks.on_stream_close_callback">
|
||||
<a class="reference internal" href="#c.nghttp2_on_stream_close_callback" title="nghttp2_on_stream_close_callback">nghttp2_on_stream_close_callback</a> <tt class="descname">on_stream_close_callback</tt><a class="headerlink" href="#c.nghttp2_session_callbacks.on_stream_close_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked when the stream is closed.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_session_callbacks.on_unknown_frame_recv_callback">
|
||||
<a class="reference internal" href="#c.nghttp2_on_unknown_frame_recv_callback" title="nghttp2_on_unknown_frame_recv_callback">nghttp2_on_unknown_frame_recv_callback</a> <tt class="descname">on_unknown_frame_recv_callback</tt><a class="headerlink" href="#c.nghttp2_session_callbacks.on_unknown_frame_recv_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked when the received frame type is
|
||||
unknown.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_session_callbacks.on_begin_headers_callback">
|
||||
<a class="reference internal" href="#c.nghttp2_on_begin_headers_callback" title="nghttp2_on_begin_headers_callback">nghttp2_on_begin_headers_callback</a> <tt class="descname">on_begin_headers_callback</tt><a class="headerlink" href="#c.nghttp2_session_callbacks.on_begin_headers_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked when the reception of header block in
|
||||
HEADERS or PUSH_PROMISE is started.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_session_callbacks.on_header_callback">
|
||||
<a class="reference internal" href="#c.nghttp2_on_header_callback" title="nghttp2_on_header_callback">nghttp2_on_header_callback</a> <tt class="descname">on_header_callback</tt><a class="headerlink" href="#c.nghttp2_session_callbacks.on_header_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked when a header name/value pair is
|
||||
received.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="member">
|
||||
<dt id="c.nghttp2_session_callbacks.select_padding_callback">
|
||||
<a class="reference internal" href="#c.nghttp2_select_padding_callback" title="nghttp2_select_padding_callback">nghttp2_select_padding_callback</a> <tt class="descname">select_padding_callback</tt><a class="headerlink" href="#c.nghttp2_session_callbacks.select_padding_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Callback function invoked when the library asks application how
|
||||
many padding bytes are required for the transmission of the given
|
||||
frame.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dd><p>Callback functions for <a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session</span></tt></a>. The details of
|
||||
this structure are intentionally hidden from the public API.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="type">
|
||||
|
@ -1972,6 +1932,128 @@ this structure are intentionally hidden from the public API.</p>
|
|||
</div>
|
||||
<div class="section" id="functions">
|
||||
<h2>Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h2>
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_new">
|
||||
int <tt class="descname">nghttp2_session_callbacks_new</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> **callbacks_ptr</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_new" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Initializes <em>*callbacks_ptr</em> with NULL values.</p>
|
||||
<p>The initialized object can be used when initializing multiple
|
||||
<a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_session</span></tt></a> objects.</p>
|
||||
<p>When the application finished using this object, it can use
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks_del" title="nghttp2_session_callbacks_del"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_callbacks_del()</span></tt></a> to free its memory.</p>
|
||||
<p>This function returns 0 if it succeeds, or one of the following
|
||||
negative error codes:</p>
|
||||
<dl class="docutils">
|
||||
<dt><a class="reference internal" href="#c.NGHTTP2_ERR_NOMEM" title="NGHTTP2_ERR_NOMEM"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_NOMEM</span></tt></a></dt>
|
||||
<dd>Out of memory.</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_del">
|
||||
void <tt class="descname">nghttp2_session_callbacks_del</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *callbacks</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_del" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Frees any resources allocated for <em>callbacks</em>. If <em>callbacks</em> is
|
||||
<tt class="docutils literal"><span class="pre">NULL</span></tt>, this function does nothing.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_set_send_callback">
|
||||
void <tt class="descname">nghttp2_session_callbacks_set_send_callback</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *cbs</em>, <a class="reference internal" href="#c.nghttp2_send_callback" title="nghttp2_send_callback">nghttp2_send_callback</a><em> send_callback</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_set_send_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Sets callback function invoked when a session wants to send data to
|
||||
the remote peer. This callback is not necessary if the application
|
||||
uses solely <a class="reference internal" href="#c.nghttp2_session_mem_send" title="nghttp2_session_mem_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_mem_send()</span></tt></a> to serialize data to
|
||||
transmit.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_set_recv_callback">
|
||||
void <tt class="descname">nghttp2_session_callbacks_set_recv_callback</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *cbs</em>, <a class="reference internal" href="#c.nghttp2_recv_callback" title="nghttp2_recv_callback">nghttp2_recv_callback</a><em> recv_callback</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_set_recv_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Sets callback function invoked when the a session wants to receive
|
||||
data from the remote peer. This callback is not necessary if the
|
||||
application uses solely <a class="reference internal" href="#c.nghttp2_session_mem_recv" title="nghttp2_session_mem_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_mem_recv()</span></tt></a> to process
|
||||
received data.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_set_on_frame_recv_callback">
|
||||
void <tt class="descname">nghttp2_session_callbacks_set_on_frame_recv_callback</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *cbs</em>, <a class="reference internal" href="#c.nghttp2_on_frame_recv_callback" title="nghttp2_on_frame_recv_callback">nghttp2_on_frame_recv_callback</a><em> on_frame_recv_callback</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_set_on_frame_recv_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Sets callback function invoked by <a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> when a
|
||||
frame is received.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_set_on_invalid_frame_recv_callback">
|
||||
void <tt class="descname">nghttp2_session_callbacks_set_on_invalid_frame_recv_callback</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *cbs</em>, <a class="reference internal" href="#c.nghttp2_on_invalid_frame_recv_callback" title="nghttp2_on_invalid_frame_recv_callback">nghttp2_on_invalid_frame_recv_callback</a><em> on_invalid_frame_recv_callback</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_set_on_invalid_frame_recv_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Sets callback function invoked by <a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> when an
|
||||
invalid non-DATA frame is received.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_set_on_data_chunk_recv_callback">
|
||||
void <tt class="descname">nghttp2_session_callbacks_set_on_data_chunk_recv_callback</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *cbs</em>, <a class="reference internal" href="#c.nghttp2_on_data_chunk_recv_callback" title="nghttp2_on_data_chunk_recv_callback">nghttp2_on_data_chunk_recv_callback</a><em> on_data_chunk_recv_callback</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_set_on_data_chunk_recv_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Sets callback function invoked when a chunk of data in DATA frame
|
||||
is received.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_set_before_frame_send_callback">
|
||||
void <tt class="descname">nghttp2_session_callbacks_set_before_frame_send_callback</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *cbs</em>, <a class="reference internal" href="#c.nghttp2_before_frame_send_callback" title="nghttp2_before_frame_send_callback">nghttp2_before_frame_send_callback</a><em> before_frame_send_callback</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_set_before_frame_send_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Sets callback function invoked before a non-DATA frame is sent.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_set_on_frame_send_callback">
|
||||
void <tt class="descname">nghttp2_session_callbacks_set_on_frame_send_callback</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *cbs</em>, <a class="reference internal" href="#c.nghttp2_on_frame_send_callback" title="nghttp2_on_frame_send_callback">nghttp2_on_frame_send_callback</a><em> on_frame_send_callback</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_set_on_frame_send_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Sets callback function invoked after a frame is sent.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_set_on_frame_not_send_callback">
|
||||
void <tt class="descname">nghttp2_session_callbacks_set_on_frame_not_send_callback</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *cbs</em>, <a class="reference internal" href="#c.nghttp2_on_frame_not_send_callback" title="nghttp2_on_frame_not_send_callback">nghttp2_on_frame_not_send_callback</a><em> on_frame_not_send_callback</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_set_on_frame_not_send_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Sets callback function invoked when a non-DATA frame is not sent
|
||||
because of an error.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_set_on_stream_close_callback">
|
||||
void <tt class="descname">nghttp2_session_callbacks_set_on_stream_close_callback</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *cbs</em>, <a class="reference internal" href="#c.nghttp2_on_stream_close_callback" title="nghttp2_on_stream_close_callback">nghttp2_on_stream_close_callback</a><em> on_stream_close_callback</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_set_on_stream_close_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Sets callback function invoked when the stream is closed.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_set_on_begin_headers_callback">
|
||||
void <tt class="descname">nghttp2_session_callbacks_set_on_begin_headers_callback</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *cbs</em>, <a class="reference internal" href="#c.nghttp2_on_begin_headers_callback" title="nghttp2_on_begin_headers_callback">nghttp2_on_begin_headers_callback</a><em> on_begin_headers_callback</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_set_on_begin_headers_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Sets callback function invoked when the reception of header block
|
||||
in HEADERS or PUSH_PROMISE is started.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_set_on_header_callback">
|
||||
void <tt class="descname">nghttp2_session_callbacks_set_on_header_callback</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *cbs</em>, <a class="reference internal" href="#c.nghttp2_on_header_callback" title="nghttp2_on_header_callback">nghttp2_on_header_callback</a><em> on_header_callback</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_set_on_header_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Sets callback function invoked when a header name/value pair is
|
||||
received.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_set_select_padding_callback">
|
||||
void <tt class="descname">nghttp2_session_callbacks_set_select_padding_callback</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *cbs</em>, <a class="reference internal" href="#c.nghttp2_select_padding_callback" title="nghttp2_select_padding_callback">nghttp2_select_padding_callback</a><em> select_padding_callback</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_set_select_padding_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Sets callback function invoked when the library asks application
|
||||
how many padding bytes are required for the transmission of the
|
||||
given frame.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_set_data_source_read_length_callback">
|
||||
void <tt class="descname">nghttp2_session_callbacks_set_data_source_read_length_callback</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *cbs</em>, <a class="reference internal" href="#c.nghttp2_data_source_read_length_callback" title="nghttp2_data_source_read_length_callback">nghttp2_data_source_read_length_callback</a><em> data_source_read_length_callback</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_set_data_source_read_length_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Sets callback function determine the length allowed in
|
||||
<a class="reference internal" href="#c.nghttp2_data_source_read_callback" title="nghttp2_data_source_read_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_data_source_read_callback</span></tt></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_callbacks_set_on_begin_frame_callback">
|
||||
void <tt class="descname">nghttp2_session_callbacks_set_on_begin_frame_callback</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session_callbacks" title="nghttp2_session_callbacks">nghttp2_session_callbacks</a><em> *cbs</em>, <a class="reference internal" href="#c.nghttp2_on_begin_frame_callback" title="nghttp2_on_begin_frame_callback">nghttp2_on_begin_frame_callback</a><em> on_begin_frame_callback</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_callbacks_set_on_begin_frame_callback" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Sets callback function invoked when a frame header is received.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_option_new">
|
||||
int <tt class="descname">nghttp2_option_new</tt><big>(</big><a class="reference internal" href="#c.nghttp2_option" title="nghttp2_option">nghttp2_option</a><em> **option_ptr</em><big>)</big><a class="headerlink" href="#c.nghttp2_option_new" title="Permalink to this definition">¶</a></dt>
|
||||
|
@ -2027,10 +2109,10 @@ int <tt class="descname">nghttp2_session_client_new</tt><big>(</big><a class="re
|
|||
<em>callbacks</em> are copied to <em>*session_ptr</em>. Therefore <em>*session_ptr</em>
|
||||
does not store <em>callbacks</em>. The <em>user_data</em> is an arbitrary user
|
||||
supplied data, which will be passed to the callback functions.</p>
|
||||
<p>The <a class="reference internal" href="#c.nghttp2_session_callbacks.send_callback" title="nghttp2_session_callbacks.send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.send_callback</span></tt></a> must be
|
||||
specified. If the application code uses <a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a>,
|
||||
the <a class="reference internal" href="#c.nghttp2_session_callbacks.recv_callback" title="nghttp2_session_callbacks.recv_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.recv_callback</span></tt></a> must be
|
||||
specified. The other members of <em>callbacks</em> can be <tt class="docutils literal"><span class="pre">NULL</span></tt>.</p>
|
||||
<p>The <a class="reference internal" href="#c.nghttp2_send_callback" title="nghttp2_send_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_send_callback</span></tt></a> must be specified. If the
|
||||
application code uses <a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a>, the
|
||||
<a class="reference internal" href="#c.nghttp2_recv_callback" title="nghttp2_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_recv_callback</span></tt></a> must be specified. The other members
|
||||
of <em>callbacks</em> can be <tt class="docutils literal"><span class="pre">NULL</span></tt>.</p>
|
||||
<p>If this function fails, <em>*session_ptr</em> is left untouched.</p>
|
||||
<p>This function returns 0 if it succeeds, or one of the following
|
||||
negative error codes:</p>
|
||||
|
@ -2047,10 +2129,10 @@ int <tt class="descname">nghttp2_session_server_new</tt><big>(</big><a class="re
|
|||
<em>callbacks</em> are copied to <em>*session_ptr</em>. Therefore <em>*session_ptr</em>
|
||||
does not store <em>callbacks</em>. The <em>user_data</em> is an arbitrary user
|
||||
supplied data, which will be passed to the callback functions.</p>
|
||||
<p>The <a class="reference internal" href="#c.nghttp2_session_callbacks.send_callback" title="nghttp2_session_callbacks.send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.send_callback</span></tt></a> must be
|
||||
specified. If the application code uses <a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a>,
|
||||
the <a class="reference internal" href="#c.nghttp2_session_callbacks.recv_callback" title="nghttp2_session_callbacks.recv_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.recv_callback</span></tt></a> must be
|
||||
specified. The other members of <em>callbacks</em> can be <tt class="docutils literal"><span class="pre">NULL</span></tt>.</p>
|
||||
<p>The <a class="reference internal" href="#c.nghttp2_send_callback" title="nghttp2_send_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_send_callback</span></tt></a> must be specified. If the
|
||||
application code uses <a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a>, the
|
||||
<a class="reference internal" href="#c.nghttp2_recv_callback" title="nghttp2_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_recv_callback</span></tt></a> must be specified. The other members
|
||||
of <em>callbacks</em> can be <tt class="docutils literal"><span class="pre">NULL</span></tt>.</p>
|
||||
<p>If this function fails, <em>*session_ptr</em> is left untouched.</p>
|
||||
<p>This function returns 0 if it succeeds, or one of the following
|
||||
negative error codes:</p>
|
||||
|
@ -2112,7 +2194,7 @@ int <tt class="descname">nghttp2_session_send</tt><big>(</big><a class="referenc
|
|||
<p>This function retrieves the highest prioritized frame from the
|
||||
outbound queue and sends it to the remote peer. It does this as
|
||||
many as possible until the user callback
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.send_callback" title="nghttp2_session_callbacks.send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.send_callback</span></tt></a> returns
|
||||
<a class="reference internal" href="#c.nghttp2_send_callback" title="nghttp2_send_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_send_callback</span></tt></a> returns
|
||||
<a class="reference internal" href="#c.NGHTTP2_ERR_WOULDBLOCK" title="NGHTTP2_ERR_WOULDBLOCK"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_WOULDBLOCK</span></tt></a> or the outbound queue becomes empty.
|
||||
This function calls several callback functions which are passed
|
||||
when initializing the <em>session</em>. Here is the simple time chart
|
||||
|
@ -2122,22 +2204,18 @@ which tells when each callback is invoked:</p>
|
|||
<li>Prepare transmission of the frame.</li>
|
||||
<li>If the control frame cannot be sent because some preconditions
|
||||
are not met (e.g., request HEADERS cannot be sent after GOAWAY),
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.on_frame_not_send_callback" title="nghttp2_session_callbacks.on_frame_not_send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.on_frame_not_send_callback</span></tt></a>
|
||||
is invoked. Abort the following steps.</li>
|
||||
<a class="reference internal" href="#c.nghttp2_on_frame_not_send_callback" title="nghttp2_on_frame_not_send_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_frame_not_send_callback</span></tt></a> is invoked. Abort
|
||||
the following steps.</li>
|
||||
<li>If the frame is HEADERS, PUSH_PROMISE or DATA,
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.select_padding_callback" title="nghttp2_session_callbacks.select_padding_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.select_padding_callback</span></tt></a> is
|
||||
invoked.</li>
|
||||
<a class="reference internal" href="#c.nghttp2_select_padding_callback" title="nghttp2_select_padding_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_select_padding_callback</span></tt></a> is invoked.</li>
|
||||
<li>If the frame is request HEADERS, the stream is opened here.</li>
|
||||
<li><a class="reference internal" href="#c.nghttp2_session_callbacks.before_frame_send_callback" title="nghttp2_session_callbacks.before_frame_send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.before_frame_send_callback</span></tt></a> is
|
||||
invoked.</li>
|
||||
<li><a class="reference internal" href="#c.nghttp2_session_callbacks.send_callback" title="nghttp2_session_callbacks.send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.send_callback</span></tt></a> is invoked one
|
||||
or more times to send the frame.</li>
|
||||
<li><a class="reference internal" href="#c.nghttp2_session_callbacks.on_frame_send_callback" title="nghttp2_session_callbacks.on_frame_send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.on_frame_send_callback</span></tt></a> is
|
||||
invoked.</li>
|
||||
<li><a class="reference internal" href="#c.nghttp2_before_frame_send_callback" title="nghttp2_before_frame_send_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_before_frame_send_callback</span></tt></a> is invoked.</li>
|
||||
<li><a class="reference internal" href="#c.nghttp2_send_callback" title="nghttp2_send_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_send_callback</span></tt></a> is invoked one or more times to
|
||||
send the frame.</li>
|
||||
<li><a class="reference internal" href="#c.nghttp2_on_frame_send_callback" title="nghttp2_on_frame_send_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_frame_send_callback</span></tt></a> is invoked.</li>
|
||||
<li>If the transmission of the frame triggers closure of the stream,
|
||||
the stream is closed and
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.on_stream_close_callback" title="nghttp2_session_callbacks.on_stream_close_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.on_stream_close_callback</span></tt></a> is
|
||||
invoked.</li>
|
||||
<a class="reference internal" href="#c.nghttp2_on_stream_close_callback" title="nghttp2_on_stream_close_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_stream_close_callback</span></tt></a> is invoked.</li>
|
||||
</ol>
|
||||
<p>This function returns 0 if it succeeds, or one of the following
|
||||
negative error codes:</p>
|
||||
|
@ -2154,11 +2232,10 @@ negative error codes:</p>
|
|||
ssize_t <tt class="descname">nghttp2_session_mem_send</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, const uint8_t<em> **data_ptr</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_mem_send" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Returns the serialized data to send.</p>
|
||||
<p>This function behaves like <a class="reference internal" href="#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a> except that it
|
||||
does not use <a class="reference internal" href="#c.nghttp2_session_callbacks.send_callback" title="nghttp2_session_callbacks.send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.send_callback</span></tt></a> to
|
||||
transmit data. Instead, it assigns the pointer to the serialized
|
||||
data to the <em>*data_ptr</em> and returns its length. The other
|
||||
callbacks are called in the same way as they are in
|
||||
<a class="reference internal" href="#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a>.</p>
|
||||
does not use <a class="reference internal" href="#c.nghttp2_send_callback" title="nghttp2_send_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_send_callback</span></tt></a> to transmit data.
|
||||
Instead, it assigns the pointer to the serialized data to the
|
||||
<em>*data_ptr</em> and returns its length. The other callbacks are called
|
||||
in the same way as they are in <a class="reference internal" href="#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a>.</p>
|
||||
<p>If no data is available to send, this function returns 0.</p>
|
||||
<p>This function may not return all serialized data in one invocation.
|
||||
To get all data, call this function repeatedly until it returns 0
|
||||
|
@ -2181,49 +2258,42 @@ codes:</p>
|
|||
int <tt class="descname">nghttp2_session_recv</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_recv" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Receives frames from the remote peer.</p>
|
||||
<p>This function receives as many frames as possible until the user
|
||||
callback <a class="reference internal" href="#c.nghttp2_session_callbacks.recv_callback" title="nghttp2_session_callbacks.recv_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.recv_callback</span></tt></a> returns
|
||||
callback <a class="reference internal" href="#c.nghttp2_recv_callback" title="nghttp2_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_recv_callback</span></tt></a> returns
|
||||
<a class="reference internal" href="#c.NGHTTP2_ERR_WOULDBLOCK" title="NGHTTP2_ERR_WOULDBLOCK"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_WOULDBLOCK</span></tt></a>. This function calls several
|
||||
callback functions which are passed when initializing the
|
||||
<em>session</em>. Here is the simple time chart which tells when each
|
||||
callback is invoked:</p>
|
||||
<ol class="arabic simple">
|
||||
<li><a class="reference internal" href="#c.nghttp2_session_callbacks.recv_callback" title="nghttp2_session_callbacks.recv_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.recv_callback</span></tt></a> is invoked one
|
||||
or more times to receive frame header.</li>
|
||||
<li><a class="reference internal" href="#c.nghttp2_recv_callback" title="nghttp2_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_recv_callback</span></tt></a> is invoked one or more times to
|
||||
receive frame header.</li>
|
||||
<li>When frame header is received,
|
||||
<a class="reference internal" href="#c.nghttp2_on_begin_frame_callback" title="nghttp2_on_begin_frame_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_begin_frame_callback</span></tt></a> is invoked.</li>
|
||||
<li>If the frame is DATA frame:<ol class="arabic">
|
||||
<li><a class="reference internal" href="#c.nghttp2_session_callbacks.recv_callback" title="nghttp2_session_callbacks.recv_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.recv_callback</span></tt></a> is invoked
|
||||
to receive DATA payload. For each chunk of data,
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.on_data_chunk_recv_callback" title="nghttp2_session_callbacks.on_data_chunk_recv_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.on_data_chunk_recv_callback</span></tt></a>
|
||||
is invoked.</li>
|
||||
<li><a class="reference internal" href="#c.nghttp2_recv_callback" title="nghttp2_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_recv_callback</span></tt></a> is invoked to receive DATA
|
||||
payload. For each chunk of data,
|
||||
<a class="reference internal" href="#c.nghttp2_on_data_chunk_recv_callback" title="nghttp2_on_data_chunk_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_data_chunk_recv_callback</span></tt></a> is invoked.</li>
|
||||
<li>If one DATA frame is completely received,
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.on_frame_recv_callback" title="nghttp2_session_callbacks.on_frame_recv_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.on_frame_recv_callback</span></tt></a> is
|
||||
invoked. If the reception of the frame triggers the
|
||||
closure of the stream,
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.on_stream_close_callback" title="nghttp2_session_callbacks.on_stream_close_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.on_stream_close_callback</span></tt></a>
|
||||
is invoked.</li>
|
||||
<a class="reference internal" href="#c.nghttp2_on_frame_recv_callback" title="nghttp2_on_frame_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_frame_recv_callback</span></tt></a> is invoked. If the
|
||||
reception of the frame triggers the closure of the stream,
|
||||
<a class="reference internal" href="#c.nghttp2_on_stream_close_callback" title="nghttp2_on_stream_close_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_stream_close_callback</span></tt></a> is invoked.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>If the frame is the control frame:<ol class="arabic">
|
||||
<li><a class="reference internal" href="#c.nghttp2_session_callbacks.recv_callback" title="nghttp2_session_callbacks.recv_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.recv_callback</span></tt></a> is invoked
|
||||
one or more times to receive whole frame.</li>
|
||||
<li><a class="reference internal" href="#c.nghttp2_recv_callback" title="nghttp2_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_recv_callback</span></tt></a> is invoked one or more times to
|
||||
receive whole frame.</li>
|
||||
<li>If the received frame is valid, then following actions are
|
||||
taken. If the frame is either HEADERS or PUSH_PROMISE,
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.on_begin_headers_callback" title="nghttp2_session_callbacks.on_begin_headers_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.on_begin_headers_callback</span></tt></a>
|
||||
is invoked. Then
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.on_header_callback" title="nghttp2_session_callbacks.on_header_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.on_header_callback</span></tt></a> is
|
||||
invoked for each header name/value pair. After all name/value
|
||||
pairs are emitted successfully,
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.on_frame_recv_callback" title="nghttp2_session_callbacks.on_frame_recv_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.on_frame_recv_callback</span></tt></a> is
|
||||
<a class="reference internal" href="#c.nghttp2_on_begin_headers_callback" title="nghttp2_on_begin_headers_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_begin_headers_callback</span></tt></a> is invoked. Then
|
||||
<a class="reference internal" href="#c.nghttp2_on_header_callback" title="nghttp2_on_header_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_header_callback</span></tt></a> is invoked for each header
|
||||
name/value pair. After all name/value pairs are emitted
|
||||
successfully, <a class="reference internal" href="#c.nghttp2_on_frame_recv_callback" title="nghttp2_on_frame_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_frame_recv_callback</span></tt></a> is
|
||||
invoked. For other frames,
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.on_frame_recv_callback" title="nghttp2_session_callbacks.on_frame_recv_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.on_frame_recv_callback</span></tt></a> is
|
||||
invoked.
|
||||
If the reception of the frame triggers the closure of the
|
||||
stream,
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.on_stream_close_callback" title="nghttp2_session_callbacks.on_stream_close_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.on_stream_close_callback</span></tt></a>
|
||||
is invoked.</li>
|
||||
<a class="reference internal" href="#c.nghttp2_on_frame_recv_callback" title="nghttp2_on_frame_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_frame_recv_callback</span></tt></a> is invoked. If the
|
||||
reception of the frame triggers the closure of the stream,
|
||||
<a class="reference internal" href="#c.nghttp2_on_stream_close_callback" title="nghttp2_on_stream_close_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_stream_close_callback</span></tt></a> is invoked.</li>
|
||||
<li>If the received frame is unpacked but is interpreted as
|
||||
invalid,
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.on_invalid_frame_recv_callback" title="nghttp2_session_callbacks.on_invalid_frame_recv_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.on_invalid_frame_recv_callback</span></tt></a>
|
||||
is invoked.</li>
|
||||
invalid, <a class="reference internal" href="#c.nghttp2_on_invalid_frame_recv_callback" title="nghttp2_on_invalid_frame_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_invalid_frame_recv_callback</span></tt></a> is
|
||||
invoked.</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
@ -2245,17 +2315,16 @@ ssize_t <tt class="descname">nghttp2_session_mem_recv</tt><big>(</big><a class="
|
|||
<dd><p>Processes data <em>in</em> as an input from the remote endpoint. The
|
||||
<em>inlen</em> indicates the number of bytes in the <em>in</em>.</p>
|
||||
<p>This function behaves like <a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a> except that it
|
||||
does not use <a class="reference internal" href="#c.nghttp2_session_callbacks.recv_callback" title="nghttp2_session_callbacks.recv_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.recv_callback</span></tt></a> to
|
||||
receive data; the <em>in</em> is the only data for the invocation of this
|
||||
function. If all bytes are processed, this function returns. The
|
||||
other callbacks are called in the same way as they are in
|
||||
<a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a>.</p>
|
||||
does not use <a class="reference internal" href="#c.nghttp2_recv_callback" title="nghttp2_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_recv_callback</span></tt></a> to receive data; the
|
||||
<em>in</em> is the only data for the invocation of this function. If all
|
||||
bytes are processed, this function returns. The other callbacks
|
||||
are called in the same way as they are in <a class="reference internal" href="#c.nghttp2_session_recv" title="nghttp2_session_recv"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_recv()</span></tt></a>.</p>
|
||||
<p>In the current implementation, this function always tries to
|
||||
processes all input data unless either an error occurs or
|
||||
<a class="reference internal" href="#c.NGHTTP2_ERR_PAUSE" title="NGHTTP2_ERR_PAUSE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_PAUSE</span></tt></a> is returned from
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.on_header_callback" title="nghttp2_session_callbacks.on_header_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.on_header_callback</span></tt></a> or
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.on_data_chunk_recv_callback" title="nghttp2_session_callbacks.on_data_chunk_recv_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.on_data_chunk_recv_callback</span></tt></a>.
|
||||
If <a class="reference internal" href="#c.NGHTTP2_ERR_PAUSE" title="NGHTTP2_ERR_PAUSE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_PAUSE</span></tt></a> is used, the return value includes the
|
||||
<a class="reference internal" href="#c.nghttp2_on_header_callback" title="nghttp2_on_header_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_header_callback</span></tt></a> or
|
||||
<a class="reference internal" href="#c.nghttp2_on_data_chunk_recv_callback" title="nghttp2_on_data_chunk_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_data_chunk_recv_callback</span></tt></a>. If
|
||||
<a class="reference internal" href="#c.NGHTTP2_ERR_PAUSE" title="NGHTTP2_ERR_PAUSE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_PAUSE</span></tt></a> is used, the return value includes the
|
||||
number of bytes which was used to produce the data or frame for the
|
||||
callback.</p>
|
||||
<p>This function returns the number of processed bytes, or one of the
|
||||
|
@ -2393,12 +2462,23 @@ that and returns effective window size.</p>
|
|||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_get_stream_remote_window_size">
|
||||
int32_t <tt class="descname">nghttp2_session_get_stream_remote_window_size</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a>*<em> session</em>, int32_t<em> stream_id</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_get_stream_remote_window_size" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Returns the remote window size for a given stream <em>stream_id</em>.
|
||||
This is the amount of flow-controlled payload (e.g., DATA) that the
|
||||
local endpoint can send without WINDOW_UPDATE.</p>
|
||||
<dd><p>Returns the remote window size for a given stream <em>stream_id</em>.</p>
|
||||
<p>This is the amount of flow-controlled payload (e.g., DATA) that the
|
||||
local endpoint can send without stream level WINDOW_UPDATE. There
|
||||
is also connection level flow control, so the effective size of
|
||||
payload that the local endpoint can actually send is
|
||||
min(<a class="reference internal" href="#c.nghttp2_session_get_stream_remote_window_size" title="nghttp2_session_get_stream_remote_window_size"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_get_stream_remote_window_size()</span></tt></a>,
|
||||
<a class="reference internal" href="#c.nghttp2_session_get_remote_window_size" title="nghttp2_session_get_remote_window_size"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_get_remote_window_size()</span></tt></a>).</p>
|
||||
<p>This function returns -1 if it fails.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_get_remote_window_size">
|
||||
int32_t <tt class="descname">nghttp2_session_get_remote_window_size</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a>*<em> session</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_get_remote_window_size" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Returns the remote window size for a connection.</p>
|
||||
<p>This function always succeeds.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_get_stream_local_close">
|
||||
int <tt class="descname">nghttp2_session_get_stream_local_close</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a>*<em> session</em>, int32_t<em> stream_id</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_get_stream_local_close" title="Permalink to this definition">¶</a></dt>
|
||||
|
@ -2415,11 +2495,12 @@ Returns 0 if it did not. Returns -1 if no such stream exists.</p>
|
|||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_terminate_session">
|
||||
int <tt class="descname">nghttp2_session_terminate_session</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, <a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code">nghttp2_error_code</a><em> error_code</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_terminate_session" title="Permalink to this definition">¶</a></dt>
|
||||
int <tt class="descname">nghttp2_session_terminate_session</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, uint32_t<em> error_code</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_terminate_session" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Signals the session so that the connection should be terminated.</p>
|
||||
<p>The last stream ID is the ID of a stream for which
|
||||
<a class="reference internal" href="#c.nghttp2_on_frame_recv_callback" title="nghttp2_on_frame_recv_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_on_frame_recv_callback</span></tt></a> was called most recently.</p>
|
||||
<p>The <em>error_code</em> is the error code of this GOAWAY frame.</p>
|
||||
<p>The <em>error_code</em> is the error code of this GOAWAY frame. The
|
||||
pre-defined error code is one of <a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code"><tt class="xref c c-macro docutils literal"><span class="pre">nghttp2_error_code</span></tt></a>.</p>
|
||||
<p>After the transmission, both <a class="reference internal" href="#c.nghttp2_session_want_read" title="nghttp2_session_want_read"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_want_read()</span></tt></a> and
|
||||
<a class="reference internal" href="#c.nghttp2_session_want_write" title="nghttp2_session_want_write"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_want_write()</span></tt></a> return 0.</p>
|
||||
<p>This function should be called when the connection should be
|
||||
|
@ -2435,7 +2516,7 @@ negative error codes:</p>
|
|||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_session_terminate_session2">
|
||||
int <tt class="descname">nghttp2_session_terminate_session2</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, int32_t<em> last_stream_id</em>, <a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code">nghttp2_error_code</a><em> error_code</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_terminate_session2" title="Permalink to this definition">¶</a></dt>
|
||||
int <tt class="descname">nghttp2_session_terminate_session2</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, int32_t<em> last_stream_id</em>, uint32_t<em> error_code</em><big>)</big><a class="headerlink" href="#c.nghttp2_session_terminate_session2" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Signals the session so that the connection should be terminated.</p>
|
||||
<p>This function behaves like <a class="reference internal" href="#c.nghttp2_session_terminate_session" title="nghttp2_session_terminate_session"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_terminate_session()</span></tt></a>,
|
||||
but the last stream ID can be specified by the application for fine
|
||||
|
@ -2612,8 +2693,8 @@ reached.</dd>
|
|||
<p class="last">This function returns assigned stream ID if it succeeds. But
|
||||
that stream is not opened yet. The application must not submit
|
||||
frame to that stream ID before
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.before_frame_send_callback" title="nghttp2_session_callbacks.before_frame_send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.before_frame_send_callback</span></tt></a> is
|
||||
called for this frame.</p>
|
||||
<a class="reference internal" href="#c.nghttp2_before_frame_send_callback" title="nghttp2_before_frame_send_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_before_frame_send_callback</span></tt></a> is called for this
|
||||
frame.</p>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
|
@ -2714,8 +2795,8 @@ reached.</dd>
|
|||
<p class="last">This function returns assigned stream ID if it succeeds and
|
||||
<em>stream_id</em> is -1. But that stream is not opened yet. The
|
||||
application must not submit frame to that stream ID before
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.before_frame_send_callback" title="nghttp2_session_callbacks.before_frame_send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.before_frame_send_callback</span></tt></a> is
|
||||
called for this frame.</p>
|
||||
<a class="reference internal" href="#c.nghttp2_before_frame_send_callback" title="nghttp2_before_frame_send_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_before_frame_send_callback</span></tt></a> is called for this
|
||||
frame.</p>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
|
@ -2769,9 +2850,10 @@ depend on itself.</dd>
|
|||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_submit_rst_stream">
|
||||
int <tt class="descname">nghttp2_submit_rst_stream</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, uint8_t<em> flags</em>, int32_t<em> stream_id</em>, <a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code">nghttp2_error_code</a><em> error_code</em><big>)</big><a class="headerlink" href="#c.nghttp2_submit_rst_stream" title="Permalink to this definition">¶</a></dt>
|
||||
int <tt class="descname">nghttp2_submit_rst_stream</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, uint8_t<em> flags</em>, int32_t<em> stream_id</em>, uint32_t<em> error_code</em><big>)</big><a class="headerlink" href="#c.nghttp2_submit_rst_stream" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Submits RST_STREAM frame to cancel/reject the stream <em>stream_id</em>
|
||||
with the error code <em>error_code</em>.</p>
|
||||
<p>The pre-defined error code is one of <a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code"><tt class="xref c c-macro docutils literal"><span class="pre">nghttp2_error_code</span></tt></a>.</p>
|
||||
<p>The <em>flags</em> is currently ignored and should be
|
||||
<a class="reference internal" href="#c.NGHTTP2_FLAG_NONE" title="NGHTTP2_FLAG_NONE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_FLAG_NONE</span></tt></a>.</p>
|
||||
<p>This function returns 0 if it succeeds, or one of the following
|
||||
|
@ -2856,8 +2938,8 @@ reached.</dd>
|
|||
<p class="last">This function returns assigned promised stream ID if it succeeds.
|
||||
But that stream is not opened yet. The application must not
|
||||
submit frame to that stream ID before
|
||||
<a class="reference internal" href="#c.nghttp2_session_callbacks.before_frame_send_callback" title="nghttp2_session_callbacks.before_frame_send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.before_frame_send_callback</span></tt></a> is
|
||||
called for this frame.</p>
|
||||
<a class="reference internal" href="#c.nghttp2_before_frame_send_callback" title="nghttp2_before_frame_send_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_before_frame_send_callback</span></tt></a> is called for this
|
||||
frame.</p>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
|
@ -2883,9 +2965,10 @@ negative error codes:</p>
|
|||
|
||||
<dl class="function">
|
||||
<dt id="c.nghttp2_submit_goaway">
|
||||
int <tt class="descname">nghttp2_submit_goaway</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, uint8_t<em> flags</em>, int32_t<em> last_stream_id</em>, <a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code">nghttp2_error_code</a><em> error_code</em>, const uint8_t<em> *opaque_data</em>, size_t<em> opaque_data_len</em><big>)</big><a class="headerlink" href="#c.nghttp2_submit_goaway" title="Permalink to this definition">¶</a></dt>
|
||||
int <tt class="descname">nghttp2_submit_goaway</tt><big>(</big><a class="reference internal" href="#c.nghttp2_session" title="nghttp2_session">nghttp2_session</a><em> *session</em>, uint8_t<em> flags</em>, int32_t<em> last_stream_id</em>, uint32_t<em> error_code</em>, const uint8_t<em> *opaque_data</em>, size_t<em> opaque_data_len</em><big>)</big><a class="headerlink" href="#c.nghttp2_submit_goaway" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Submits GOAWAY frame with the last stream ID <em>last_stream_id</em> and
|
||||
the error code <em>error_code</em>.</p>
|
||||
<p>The pre-defined error code is one of <a class="reference internal" href="#c.nghttp2_error_code" title="nghttp2_error_code"><tt class="xref c c-macro docutils literal"><span class="pre">nghttp2_error_code</span></tt></a>.</p>
|
||||
<p>The <em>flags</em> is currently ignored and should be
|
||||
<a class="reference internal" href="#c.NGHTTP2_FLAG_NONE" title="NGHTTP2_FLAG_NONE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_FLAG_NONE</span></tt></a>.</p>
|
||||
<p>If the <em>opaque_data</em> is not <tt class="docutils literal"><span class="pre">NULL</span></tt> and <em>opaque_data_len</em> is not
|
||||
|
|
|
@ -1776,6 +1776,10 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_data_source_read_length_callback">nghttp2_data_source_read_length_callback (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_DEFAULT_HEADER_TABLE_SIZE">NGHTTP2_DEFAULT_HEADER_TABLE_SIZE (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
@ -2255,8 +2259,6 @@
|
|||
<dt><a href="apiref.html#c.NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE">NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE (C macro)</a>
|
||||
</dt>
|
||||
|
||||
</dl></td>
|
||||
<td style="width: 33%" valign="top"><dl>
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS">NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS (C macro)</a>
|
||||
</dt>
|
||||
|
@ -2265,6 +2267,8 @@
|
|||
<dt><a href="apiref.html#c.NGHTTP2_INITIAL_WINDOW_SIZE">NGHTTP2_INITIAL_WINDOW_SIZE (C macro)</a>
|
||||
</dt>
|
||||
|
||||
</dl></td>
|
||||
<td style="width: 33%" valign="top"><dl>
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_INTERNAL_ERROR">NGHTTP2_INTERNAL_ERROR (C macro)</a>
|
||||
</dt>
|
||||
|
@ -2330,6 +2334,10 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_on_begin_frame_callback">nghttp2_on_begin_frame_callback (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_on_begin_headers_callback">nghttp2_on_begin_headers_callback (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
@ -2362,10 +2370,6 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_on_unknown_frame_recv_callback">nghttp2_on_unknown_frame_recv_callback (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_option">nghttp2_option (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
@ -2530,55 +2534,67 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks.before_frame_send_callback">nghttp2_session_callbacks.before_frame_send_callback (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_del">nghttp2_session_callbacks_del (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks.on_begin_headers_callback">nghttp2_session_callbacks.on_begin_headers_callback (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_new">nghttp2_session_callbacks_new (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks.on_data_chunk_recv_callback">nghttp2_session_callbacks.on_data_chunk_recv_callback (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_set_before_frame_send_callback">nghttp2_session_callbacks_set_before_frame_send_callback (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks.on_frame_not_send_callback">nghttp2_session_callbacks.on_frame_not_send_callback (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_set_data_source_read_length_callback">nghttp2_session_callbacks_set_data_source_read_length_callback (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks.on_frame_recv_callback">nghttp2_session_callbacks.on_frame_recv_callback (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_set_on_begin_frame_callback">nghttp2_session_callbacks_set_on_begin_frame_callback (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks.on_frame_send_callback">nghttp2_session_callbacks.on_frame_send_callback (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_set_on_begin_headers_callback">nghttp2_session_callbacks_set_on_begin_headers_callback (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks.on_header_callback">nghttp2_session_callbacks.on_header_callback (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_set_on_data_chunk_recv_callback">nghttp2_session_callbacks_set_on_data_chunk_recv_callback (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks.on_invalid_frame_recv_callback">nghttp2_session_callbacks.on_invalid_frame_recv_callback (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_set_on_frame_not_send_callback">nghttp2_session_callbacks_set_on_frame_not_send_callback (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks.on_stream_close_callback">nghttp2_session_callbacks.on_stream_close_callback (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_set_on_frame_recv_callback">nghttp2_session_callbacks_set_on_frame_recv_callback (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks.on_unknown_frame_recv_callback">nghttp2_session_callbacks.on_unknown_frame_recv_callback (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_set_on_frame_send_callback">nghttp2_session_callbacks_set_on_frame_send_callback (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks.recv_callback">nghttp2_session_callbacks.recv_callback (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_set_on_header_callback">nghttp2_session_callbacks_set_on_header_callback (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks.select_padding_callback">nghttp2_session_callbacks.select_padding_callback (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_set_on_invalid_frame_recv_callback">nghttp2_session_callbacks_set_on_invalid_frame_recv_callback (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks.send_callback">nghttp2_session_callbacks.send_callback (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_set_on_stream_close_callback">nghttp2_session_callbacks_set_on_stream_close_callback (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_set_recv_callback">nghttp2_session_callbacks_set_recv_callback (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_set_select_padding_callback">nghttp2_session_callbacks_set_select_padding_callback (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_callbacks_set_send_callback">nghttp2_session_callbacks_set_send_callback (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
|
@ -2614,6 +2630,10 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_get_remote_window_size">nghttp2_session_get_remote_window_size (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_get_stream_effective_local_window_size">nghttp2_session_get_stream_effective_local_window_size (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
|
502
nghttp2.h.html
502
nghttp2.h.html
|
@ -792,7 +792,7 @@
|
|||
<span class="cm"> */</span>
|
||||
<span class="kt">int32_t</span> <span class="n">stream_id</span><span class="p">;</span>
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * The type of this frame. See `nghttp2_frame`.</span>
|
||||
<span class="cm"> * The type of this frame. See `nghttp2_frame_type`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="kt">uint8_t</span> <span class="n">type</span><span class="p">;</span>
|
||||
<span class="cm">/**</span>
|
||||
|
@ -1015,7 +1015,7 @@
|
|||
<span class="cm">/**</span>
|
||||
<span class="cm"> * The error code. See :type:`nghttp2_error_code`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_error_code</span> <span class="n">error_code</span><span class="p">;</span>
|
||||
<span class="kt">uint32_t</span> <span class="n">error_code</span><span class="p">;</span>
|
||||
<span class="p">}</span> <span class="n">nghttp2_rst_stream</span><span class="p">;</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
|
@ -1116,7 +1116,7 @@
|
|||
<span class="cm">/**</span>
|
||||
<span class="cm"> * The error code. See :type:`nghttp2_error_code`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_error_code</span> <span class="n">error_code</span><span class="p">;</span>
|
||||
<span class="kt">uint32_t</span> <span class="n">error_code</span><span class="p">;</span>
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * The additional debug data</span>
|
||||
<span class="cm"> */</span>
|
||||
|
@ -1274,6 +1274,9 @@
|
|||
<span class="cm"> * `nghttp2_session_send()` to send data to the remote endpoint. If</span>
|
||||
<span class="cm"> * the application uses solely `nghttp2_session_mem_send()` instead,</span>
|
||||
<span class="cm"> * this callback function is unnecessary.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * To set this callback to :type:`nghttp2_session_callbacks`, use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_set_send_callback()`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">ssize_t</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_send_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span>
|
||||
|
@ -1299,6 +1302,9 @@
|
|||
<span class="cm"> * `nghttp2_session_recv()` to receive data from the remote endpoint.</span>
|
||||
<span class="cm"> * If the application uses solely `nghttp2_session_mem_recv()`</span>
|
||||
<span class="cm"> * instead, this callback function is unnecessary.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * To set this callback to :type:`nghttp2_session_callbacks`, use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_set_recv_callback()`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">ssize_t</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_recv_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span>
|
||||
|
@ -1327,10 +1333,16 @@
|
|||
<span class="cm"> * If ``frame->hd.flags & NGHTTP2_FLAG_END_STREAM`` is nonzero, the</span>
|
||||
<span class="cm"> * |frame| is the last frame from the remote peer in this stream.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * This callback won't be called for CONTINUATION frames.</span>
|
||||
<span class="cm"> * HEADERS/PUSH_PROMISE + CONTINUATIONs are treated as single frame.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * The implementation of this function must return 0 if it succeeds.</span>
|
||||
<span class="cm"> * If nonzero value is returned, it is treated as fatal error and</span>
|
||||
<span class="cm"> * `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions</span>
|
||||
<span class="cm"> * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * To set this callback to :type:`nghttp2_session_callbacks`, use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_set_on_frame_recv_callback()`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">int</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_on_frame_recv_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="k">const</span> <span class="n">nghttp2_frame</span> <span class="o">*</span><span class="n">frame</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">);</span>
|
||||
|
@ -1339,12 +1351,13 @@
|
|||
<span class="cm"> * @functypedef</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Callback function invoked by `nghttp2_session_recv()` when an</span>
|
||||
<span class="cm"> * invalid non-DATA frame is received. The |error_code| is one of the</span>
|
||||
<span class="cm"> * :enum:`nghttp2_error_code` and indicates the error. When this</span>
|
||||
<span class="cm"> * callback function is invoked, the library automatically submits</span>
|
||||
<span class="cm"> * either RST_STREAM or GOAWAY frame. The |user_data| pointer is the</span>
|
||||
<span class="cm"> * third argument passed in to the call to</span>
|
||||
<span class="cm"> * `nghttp2_session_client_new()` or `nghttp2_session_server_new()`.</span>
|
||||
<span class="cm"> * invalid non-DATA frame is received. The |error_code| indicates the</span>
|
||||
<span class="cm"> * error. It is usually one of the :enum:`nghttp2_error_code` but</span>
|
||||
<span class="cm"> * that is not guaranteed. When this callback function is invoked,</span>
|
||||
<span class="cm"> * the library automatically submits either RST_STREAM or GOAWAY</span>
|
||||
<span class="cm"> * frame. The |user_data| pointer is the third argument passed in to</span>
|
||||
<span class="cm"> * the call to `nghttp2_session_client_new()` or</span>
|
||||
<span class="cm"> * `nghttp2_session_server_new()`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * If frame is HEADERS or PUSH_PROMISE, the ``nva`` and ``nvlen``</span>
|
||||
<span class="cm"> * member of their data structure are always ``NULL`` and 0</span>
|
||||
|
@ -1354,10 +1367,13 @@
|
|||
<span class="cm"> * If nonzero is returned, it is treated as fatal error and</span>
|
||||
<span class="cm"> * `nghttp2_session_recv()` and `nghttp2_session_send()` functions</span>
|
||||
<span class="cm"> * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * To set this callback to :type:`nghttp2_session_callbacks`, use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_set_on_invalid_frame_recv_callback()`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">int</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_on_invalid_frame_recv_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="k">const</span> <span class="n">nghttp2_frame</span> <span class="o">*</span><span class="n">frame</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_error_code</span> <span class="n">error_code</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">);</span>
|
||||
<span class="kt">uint32_t</span> <span class="n">error_code</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * @functypedef</span>
|
||||
|
@ -1385,6 +1401,9 @@
|
|||
<span class="cm"> * If nonzero is returned, it is treated as fatal error and</span>
|
||||
<span class="cm"> * `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions</span>
|
||||
<span class="cm"> * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * To set this callback to :type:`nghttp2_session_callbacks`, use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_set_on_data_chunk_recv_callback()`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">int</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_on_data_chunk_recv_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="kt">uint8_t</span> <span class="n">flags</span><span class="p">,</span> <span class="kt">int32_t</span> <span class="n">stream_id</span><span class="p">,</span>
|
||||
|
@ -1402,6 +1421,9 @@
|
|||
<span class="cm"> * If nonzero is returned, it is treated as fatal error and</span>
|
||||
<span class="cm"> * `nghttp2_session_recv()` and `nghttp2_session_send()` functions</span>
|
||||
<span class="cm"> * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * To set this callback to :type:`nghttp2_session_callbacks`, use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_set_before_frame_send_callback()`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">int</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_before_frame_send_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="k">const</span> <span class="n">nghttp2_frame</span> <span class="o">*</span><span class="n">frame</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">);</span>
|
||||
|
@ -1417,6 +1439,9 @@
|
|||
<span class="cm"> * If nonzero is returned, it is treated as fatal error and</span>
|
||||
<span class="cm"> * `nghttp2_session_recv()` and `nghttp2_session_send()` functions</span>
|
||||
<span class="cm"> * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * To set this callback to :type:`nghttp2_session_callbacks`, use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_set_on_frame_send_callback()`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">int</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_on_frame_send_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="k">const</span> <span class="n">nghttp2_frame</span> <span class="o">*</span><span class="n">frame</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">);</span>
|
||||
|
@ -1435,6 +1460,9 @@
|
|||
<span class="cm"> * If nonzero is returned, it is treated as fatal error and</span>
|
||||
<span class="cm"> * `nghttp2_session_recv()` and `nghttp2_session_send()` functions</span>
|
||||
<span class="cm"> * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * To set this callback to :type:`nghttp2_session_callbacks`, use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_set_on_frame_not_send_callback()`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">int</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_on_frame_not_send_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="k">const</span> <span class="n">nghttp2_frame</span> <span class="o">*</span><span class="n">frame</span><span class="p">,</span> <span class="kt">int</span> <span class="n">lib_error_code</span><span class="p">,</span>
|
||||
|
@ -1445,10 +1473,11 @@
|
|||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Callback function invoked when the stream |stream_id| is closed.</span>
|
||||
<span class="cm"> * The reason of closure is indicated by the |error_code|. The</span>
|
||||
<span class="cm"> * stream_user_data, which was specified in `nghttp2_submit_request()`</span>
|
||||
<span class="cm"> * or `nghttp2_submit_headers()`, is still available in this function.</span>
|
||||
<span class="cm"> * The |user_data| pointer is the third argument passed in to the call</span>
|
||||
<span class="cm"> * to `nghttp2_session_client_new()` or</span>
|
||||
<span class="cm"> * |error_code| is usually one of :enum:`nghttp2_error_code`, but that</span>
|
||||
<span class="cm"> * is not guaranteed. The stream_user_data, which was specified in</span>
|
||||
<span class="cm"> * `nghttp2_submit_request()` or `nghttp2_submit_headers()`, is still</span>
|
||||
<span class="cm"> * available in this function. The |user_data| pointer is the third</span>
|
||||
<span class="cm"> * argument passed in to the call to `nghttp2_session_client_new()` or</span>
|
||||
<span class="cm"> * `nghttp2_session_server_new()`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * This function is also called for a stream in reserved state.</span>
|
||||
|
@ -1457,33 +1486,12 @@
|
|||
<span class="cm"> * If nonzero is returned, it is treated as fatal error and</span>
|
||||
<span class="cm"> * `nghttp2_session_recv()` and `nghttp2_session_send()` functions</span>
|
||||
<span class="cm"> * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * To set this callback to :type:`nghttp2_session_callbacks`, use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_set_on_stream_close_callback()`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">int</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_on_stream_close_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="kt">int32_t</span> <span class="n">stream_id</span><span class="p">,</span> <span class="n">nghttp2_error_code</span> <span class="n">error_code</span><span class="p">,</span>
|
||||
<span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * @functypedef</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Callback function invoked when the received frame type is unknown.</span>
|
||||
<span class="cm"> * The |head| is the pointer to the header of the received frame. The</span>
|
||||
<span class="cm"> * |headlen| is the length of the |head|. According to the spec, the</span>
|
||||
<span class="cm"> * |headlen| is always 8. In other words, the |head| is the first 8</span>
|
||||
<span class="cm"> * bytes of the received frame. The |payload| is the pointer to the</span>
|
||||
<span class="cm"> * data portion of the received frame. The |payloadlen| is the length</span>
|
||||
<span class="cm"> * of the |payload|. This is the data after the length field. The</span>
|
||||
<span class="cm"> * |user_data| pointer is the third argument passed in to the call to</span>
|
||||
<span class="cm"> * `nghttp2_session_client_new()` or `nghttp2_session_server_new()`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * The implementation of this function must return 0 if it succeeds.</span>
|
||||
<span class="cm"> * If nonzero is returned, it is treated as fatal error and</span>
|
||||
<span class="cm"> * `nghttp2_session_recv()` and `nghttp2_session_send()` functions</span>
|
||||
<span class="cm"> * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">int</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_on_unknown_frame_recv_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span>
|
||||
<span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span><span class="n">head</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">headlen</span><span class="p">,</span>
|
||||
<span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span><span class="n">payload</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">payloadlen</span><span class="p">,</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="kt">int32_t</span> <span class="n">stream_id</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="n">error_code</span><span class="p">,</span>
|
||||
<span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
|
@ -1506,6 +1514,9 @@
|
|||
<span class="cm"> * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` is returned,</span>
|
||||
<span class="cm"> * `nghttp2_session_mem_recv()` function will immediately return</span>
|
||||
<span class="cm"> * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * To set this callback to :type:`nghttp2_session_callbacks`, use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_set_on_begin_headers_callback()`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">int</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_on_begin_headers_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="k">const</span> <span class="n">nghttp2_frame</span> <span class="o">*</span><span class="n">frame</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">);</span>
|
||||
|
@ -1567,6 +1578,9 @@
|
|||
<span class="cm"> * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` is returned,</span>
|
||||
<span class="cm"> * `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions</span>
|
||||
<span class="cm"> * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * To set this callback to :type:`nghttp2_session_callbacks`, use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_set_on_header_callback()`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">int</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_on_header_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span>
|
||||
|
@ -1589,6 +1603,9 @@
|
|||
<span class="cm"> * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` will make</span>
|
||||
<span class="cm"> * `nghttp2_session_send()` function immediately return</span>
|
||||
<span class="cm"> * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * To set this callback to :type:`nghttp2_session_callbacks`, use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_set_select_padding_callback()`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">ssize_t</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_select_padding_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span>
|
||||
|
@ -1596,80 +1613,238 @@
|
|||
<span class="kt">size_t</span> <span class="n">max_payloadlen</span><span class="p">,</span>
|
||||
<span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * @functypedef</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Callback function invoked when library wants to get max length of</span>
|
||||
<span class="cm"> * data to send data to the remote peer. The implementation of this</span>
|
||||
<span class="cm"> * function should return a value in the following range. [1,</span>
|
||||
<span class="cm"> * min(|session_remote_window_size|, |stream_remote_window_size|,</span>
|
||||
<span class="cm"> * |remote_max_frame_size|)]. If a value greater than this range is</span>
|
||||
<span class="cm"> * returned than the max allow value will be used. Returning a value</span>
|
||||
<span class="cm"> * smaller than this range is treated as</span>
|
||||
<span class="cm"> * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. The |frame_type| is provided</span>
|
||||
<span class="cm"> * for future extensibility and identifies the type of frame (see</span>
|
||||
<span class="cm"> * :type:`nghttp2_frame_type`) for which to get the length for.</span>
|
||||
<span class="cm"> * Currently supported frame types are: :enum:`NGHTTP2_DATA`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * This callback can be used to control the length in bytes for which</span>
|
||||
<span class="cm"> * :type:`nghttp2_data_source_read_callback` is allowed to send to the</span>
|
||||
<span class="cm"> * remote endpoint. This callback is optional. Returning</span>
|
||||
<span class="cm"> * :enum:`NGHTTP2_ERR_CALLBACK_FAILURE` will signal the entire session</span>
|
||||
<span class="cm"> * failure.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * To set this callback to :type:`nghttp2_session_callbacks`, use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_set_data_source_read_length_callback()`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">ssize_t</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_data_source_read_length_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="kt">uint8_t</span> <span class="n">frame_type</span><span class="p">,</span> <span class="kt">int32_t</span> <span class="n">stream_id</span><span class="p">,</span>
|
||||
<span class="kt">int32_t</span> <span class="n">session_remote_window_size</span><span class="p">,</span>
|
||||
<span class="kt">int32_t</span> <span class="n">stream_remote_window_size</span><span class="p">,</span>
|
||||
<span class="kt">uint32_t</span> <span class="n">remote_max_frame_size</span><span class="p">,</span>
|
||||
<span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * @functypedef</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Callback function invoked when a frame header is received. The</span>
|
||||
<span class="cm"> * |hd| points to received frame header.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Unlike :type:`nghttp2_on_frame_recv_callback`, this callback will</span>
|
||||
<span class="cm"> * also be called when frame header of CONTINUATION frame is received.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * If both :type:`nghttp2_on_begin_frame_callback` and</span>
|
||||
<span class="cm"> * :type:`nghttp2_on_begin_headers_callback` are set and HEADERS or</span>
|
||||
<span class="cm"> * PUSH_PROMISE is received, :type:`nghttp2_on_begin_frame_callback`</span>
|
||||
<span class="cm"> * will be called first.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * The implementation of this function must return 0 if it succeeds.</span>
|
||||
<span class="cm"> * If nonzero value is returned, it is treated as fatal error and</span>
|
||||
<span class="cm"> * `nghttp2_session_recv()` and `nghttp2_session_mem_recv()` functions</span>
|
||||
<span class="cm"> * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * To set this callback to :type:`nghttp2_session_callbacks`, use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_set_on_begin_frame_callback()`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="nf">int</span> <span class="p">(</span><span class="o">*</span><span class="n">nghttp2_on_begin_frame_callback</span><span class="p">)</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="k">const</span> <span class="n">nghttp2_frame_hd</span> <span class="o">*</span><span class="n">hd</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">);</span>
|
||||
|
||||
<span class="k">struct</span> <span class="n">nghttp2_session_callbacks</span><span class="p">;</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * @struct</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Callback functions.</span>
|
||||
<span class="cm"> * Callback functions for :type:`nghttp2_session`. The details of</span>
|
||||
<span class="cm"> * this structure are intentionally hidden from the public API.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span>
|
||||
<span class="k">typedef</span> <span class="k">struct</span> <span class="n">nghttp2_session_callbacks</span> <span class="n">nghttp2_session_callbacks</span><span class="p">;</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * Callback function invoked when the |session| wants to send data</span>
|
||||
<span class="cm"> * to the remote peer. This callback is not necessary if the</span>
|
||||
<span class="cm"> * application uses solely `nghttp2_session_mem_send()` to serialize</span>
|
||||
<span class="cm"> * data to transmit.</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Initializes |*callbacks_ptr| with NULL values.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * The initialized object can be used when initializing multiple</span>
|
||||
<span class="cm"> * :type:`nghttp2_session` objects.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * When the application finished using this object, it can use</span>
|
||||
<span class="cm"> * `nghttp2_session_callbacks_del()` to free its memory.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * This function returns 0 if it succeeds, or one of the following</span>
|
||||
<span class="cm"> * negative error codes:</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * :enum:`NGHTTP2_ERR_NOMEM`</span>
|
||||
<span class="cm"> * Out of memory.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_send_callback</span> <span class="n">send_callback</span><span class="p">;</span>
|
||||
<span class="kt">int</span> <span class="nf">nghttp2_session_callbacks_new</span><span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">**</span><span class="n">callbacks_ptr</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * Callback function invoked when the |session| wants to receive</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Frees any resources allocated for |callbacks|. If |callbacks| is</span>
|
||||
<span class="cm"> * ``NULL``, this function does nothing.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_del</span><span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">callbacks</span><span class="p">);</span>
|
||||
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Sets callback function invoked when a session wants to send data to</span>
|
||||
<span class="cm"> * the remote peer. This callback is not necessary if the application</span>
|
||||
<span class="cm"> * uses solely `nghttp2_session_mem_send()` to serialize data to</span>
|
||||
<span class="cm"> * transmit.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_set_send_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">cbs</span><span class="p">,</span> <span class="n">nghttp2_send_callback</span> <span class="n">send_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Sets callback function invoked when the a session wants to receive</span>
|
||||
<span class="cm"> * data from the remote peer. This callback is not necessary if the</span>
|
||||
<span class="cm"> * application uses solely `nghttp2_session_mem_recv()` to process</span>
|
||||
<span class="cm"> * received data.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_recv_callback</span> <span class="n">recv_callback</span><span class="p">;</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_set_recv_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">cbs</span><span class="p">,</span> <span class="n">nghttp2_recv_callback</span> <span class="n">recv_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * Callback function invoked by `nghttp2_session_recv()` when a</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Sets callback function invoked by `nghttp2_session_recv()` when a</span>
|
||||
<span class="cm"> * frame is received.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_on_frame_recv_callback</span> <span class="n">on_frame_recv_callback</span><span class="p">;</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_set_on_frame_recv_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">cbs</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_on_frame_recv_callback</span> <span class="n">on_frame_recv_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * Callback function invoked by `nghttp2_session_recv()` when an</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Sets callback function invoked by `nghttp2_session_recv()` when an</span>
|
||||
<span class="cm"> * invalid non-DATA frame is received.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_on_invalid_frame_recv_callback</span> <span class="n">on_invalid_frame_recv_callback</span><span class="p">;</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_set_on_invalid_frame_recv_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">cbs</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_on_invalid_frame_recv_callback</span> <span class="n">on_invalid_frame_recv_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * Callback function invoked when a chunk of data in DATA frame is</span>
|
||||
<span class="cm"> * received.</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Sets callback function invoked when a chunk of data in DATA frame</span>
|
||||
<span class="cm"> * is received.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_on_data_chunk_recv_callback</span> <span class="n">on_data_chunk_recv_callback</span><span class="p">;</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_set_on_data_chunk_recv_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">cbs</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_on_data_chunk_recv_callback</span> <span class="n">on_data_chunk_recv_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * Callback function invoked before a non-DATA frame is sent.</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Sets callback function invoked before a non-DATA frame is sent.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_before_frame_send_callback</span> <span class="n">before_frame_send_callback</span><span class="p">;</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_set_before_frame_send_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">cbs</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_before_frame_send_callback</span> <span class="n">before_frame_send_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * Callback function invoked after a frame is sent.</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Sets callback function invoked after a frame is sent.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_on_frame_send_callback</span> <span class="n">on_frame_send_callback</span><span class="p">;</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_set_on_frame_send_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">cbs</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_on_frame_send_callback</span> <span class="n">on_frame_send_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * The callback function invoked when a non-DATA frame is not sent</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Sets callback function invoked when a non-DATA frame is not sent</span>
|
||||
<span class="cm"> * because of an error.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_on_frame_not_send_callback</span> <span class="n">on_frame_not_send_callback</span><span class="p">;</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_set_on_frame_not_send_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">cbs</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_on_frame_not_send_callback</span> <span class="n">on_frame_not_send_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * Callback function invoked when the stream is closed.</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Sets callback function invoked when the stream is closed.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_on_stream_close_callback</span> <span class="n">on_stream_close_callback</span><span class="p">;</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_set_on_stream_close_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">cbs</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_on_stream_close_callback</span> <span class="n">on_stream_close_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * Callback function invoked when the received frame type is</span>
|
||||
<span class="cm"> * unknown.</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Sets callback function invoked when the reception of header block</span>
|
||||
<span class="cm"> * in HEADERS or PUSH_PROMISE is started.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_on_unknown_frame_recv_callback</span> <span class="n">on_unknown_frame_recv_callback</span><span class="p">;</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_set_on_begin_headers_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">cbs</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_on_begin_headers_callback</span> <span class="n">on_begin_headers_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * Callback function invoked when the reception of header block in</span>
|
||||
<span class="cm"> * HEADERS or PUSH_PROMISE is started.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_on_begin_headers_callback</span> <span class="n">on_begin_headers_callback</span><span class="p">;</span>
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * Callback function invoked when a header name/value pair is</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Sets callback function invoked when a header name/value pair is</span>
|
||||
<span class="cm"> * received.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_on_header_callback</span> <span class="n">on_header_callback</span><span class="p">;</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_set_on_header_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">cbs</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_on_header_callback</span> <span class="n">on_header_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * Callback function invoked when the library asks application how</span>
|
||||
<span class="cm"> * many padding bytes are required for the transmission of the given</span>
|
||||
<span class="cm"> * frame.</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Sets callback function invoked when the library asks application</span>
|
||||
<span class="cm"> * how many padding bytes are required for the transmission of the</span>
|
||||
<span class="cm"> * given frame.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="n">nghttp2_select_padding_callback</span> <span class="n">select_padding_callback</span><span class="p">;</span>
|
||||
<span class="p">}</span> <span class="n">nghttp2_session_callbacks</span><span class="p">;</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_set_select_padding_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">cbs</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_select_padding_callback</span> <span class="n">select_padding_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Sets callback function determine the length allowed in</span>
|
||||
<span class="cm"> * :type:`nghttp2_data_source_read_callback`.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_set_data_source_read_length_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">cbs</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_data_source_read_length_callback</span> <span class="n">data_source_read_length_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Sets callback function invoked when a frame header is received.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="kt">void</span> <span class="nf">nghttp2_session_callbacks_set_on_begin_frame_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">cbs</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_on_begin_frame_callback</span> <span class="n">on_begin_frame_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="k">struct</span> <span class="n">nghttp2_option</span><span class="p">;</span>
|
||||
|
||||
|
@ -1743,10 +1918,10 @@
|
|||
<span class="cm"> * does not store |callbacks|. The |user_data| is an arbitrary user</span>
|
||||
<span class="cm"> * supplied data, which will be passed to the callback functions.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * The :member:`nghttp2_session_callbacks.send_callback` must be</span>
|
||||
<span class="cm"> * specified. If the application code uses `nghttp2_session_recv()`,</span>
|
||||
<span class="cm"> * the :member:`nghttp2_session_callbacks.recv_callback` must be</span>
|
||||
<span class="cm"> * specified. The other members of |callbacks| can be ``NULL``.</span>
|
||||
<span class="cm"> * The :type:`nghttp2_send_callback` must be specified. If the</span>
|
||||
<span class="cm"> * application code uses `nghttp2_session_recv()`, the</span>
|
||||
<span class="cm"> * :type:`nghttp2_recv_callback` must be specified. The other members</span>
|
||||
<span class="cm"> * of |callbacks| can be ``NULL``.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * If this function fails, |*session_ptr| is left untouched.</span>
|
||||
<span class="cm"> *</span>
|
||||
|
@ -1768,10 +1943,10 @@
|
|||
<span class="cm"> * does not store |callbacks|. The |user_data| is an arbitrary user</span>
|
||||
<span class="cm"> * supplied data, which will be passed to the callback functions.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * The :member:`nghttp2_session_callbacks.send_callback` must be</span>
|
||||
<span class="cm"> * specified. If the application code uses `nghttp2_session_recv()`,</span>
|
||||
<span class="cm"> * the :member:`nghttp2_session_callbacks.recv_callback` must be</span>
|
||||
<span class="cm"> * specified. The other members of |callbacks| can be ``NULL``.</span>
|
||||
<span class="cm"> * The :type:`nghttp2_send_callback` must be specified. If the</span>
|
||||
<span class="cm"> * application code uses `nghttp2_session_recv()`, the</span>
|
||||
<span class="cm"> * :type:`nghttp2_recv_callback` must be specified. The other members</span>
|
||||
<span class="cm"> * of |callbacks| can be ``NULL``.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * If this function fails, |*session_ptr| is left untouched.</span>
|
||||
<span class="cm"> *</span>
|
||||
|
@ -1853,32 +2028,36 @@
|
|||
<span class="cm"> * This function retrieves the highest prioritized frame from the</span>
|
||||
<span class="cm"> * outbound queue and sends it to the remote peer. It does this as</span>
|
||||
<span class="cm"> * many as possible until the user callback</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.send_callback` returns</span>
|
||||
<span class="cm"> * :type:`nghttp2_send_callback` returns</span>
|
||||
<span class="cm"> * :enum:`NGHTTP2_ERR_WOULDBLOCK` or the outbound queue becomes empty.</span>
|
||||
<span class="cm"> * This function calls several callback functions which are passed</span>
|
||||
<span class="cm"> * when initializing the |session|. Here is the simple time chart</span>
|
||||
<span class="cm"> * which tells when each callback is invoked:</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 1. Get the next frame to send from outbound queue.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 2. Prepare transmission of the frame.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 3. If the control frame cannot be sent because some preconditions</span>
|
||||
<span class="cm"> * are not met (e.g., request HEADERS cannot be sent after GOAWAY),</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.on_frame_not_send_callback`</span>
|
||||
<span class="cm"> * is invoked. Abort the following steps.</span>
|
||||
<span class="cm"> * :type:`nghttp2_on_frame_not_send_callback` is invoked. Abort</span>
|
||||
<span class="cm"> * the following steps.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 4. If the frame is HEADERS, PUSH_PROMISE or DATA,</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.select_padding_callback` is</span>
|
||||
<span class="cm"> * invoked.</span>
|
||||
<span class="cm"> * :type:`nghttp2_select_padding_callback` is invoked.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 5. If the frame is request HEADERS, the stream is opened here.</span>
|
||||
<span class="cm"> * 6. :member:`nghttp2_session_callbacks.before_frame_send_callback` is</span>
|
||||
<span class="cm"> * invoked.</span>
|
||||
<span class="cm"> * 7. :member:`nghttp2_session_callbacks.send_callback` is invoked one</span>
|
||||
<span class="cm"> * or more times to send the frame.</span>
|
||||
<span class="cm"> * 8. :member:`nghttp2_session_callbacks.on_frame_send_callback` is</span>
|
||||
<span class="cm"> * invoked.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 6. :type:`nghttp2_before_frame_send_callback` is invoked.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 7. :type:`nghttp2_send_callback` is invoked one or more times to</span>
|
||||
<span class="cm"> * send the frame.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 8. :type:`nghttp2_on_frame_send_callback` is invoked.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 9. If the transmission of the frame triggers closure of the stream,</span>
|
||||
<span class="cm"> * the stream is closed and</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.on_stream_close_callback` is</span>
|
||||
<span class="cm"> * invoked.</span>
|
||||
<span class="cm"> * :type:`nghttp2_on_stream_close_callback` is invoked.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * This function returns 0 if it succeeds, or one of the following</span>
|
||||
<span class="cm"> * negative error codes:</span>
|
||||
|
@ -1896,11 +2075,10 @@
|
|||
<span class="cm"> * Returns the serialized data to send.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * This function behaves like `nghttp2_session_send()` except that it</span>
|
||||
<span class="cm"> * does not use :member:`nghttp2_session_callbacks.send_callback` to</span>
|
||||
<span class="cm"> * transmit data. Instead, it assigns the pointer to the serialized</span>
|
||||
<span class="cm"> * data to the |*data_ptr| and returns its length. The other</span>
|
||||
<span class="cm"> * callbacks are called in the same way as they are in</span>
|
||||
<span class="cm"> * `nghttp2_session_send()`.</span>
|
||||
<span class="cm"> * does not use :type:`nghttp2_send_callback` to transmit data.</span>
|
||||
<span class="cm"> * Instead, it assigns the pointer to the serialized data to the</span>
|
||||
<span class="cm"> * |*data_ptr| and returns its length. The other callbacks are called</span>
|
||||
<span class="cm"> * in the same way as they are in `nghttp2_session_send()`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * If no data is available to send, this function returns 0.</span>
|
||||
<span class="cm"> *</span>
|
||||
|
@ -1930,51 +2108,48 @@
|
|||
<span class="cm"> * Receives frames from the remote peer.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * This function receives as many frames as possible until the user</span>
|
||||
<span class="cm"> * callback :member:`nghttp2_session_callbacks.recv_callback` returns</span>
|
||||
<span class="cm"> * callback :type:`nghttp2_recv_callback` returns</span>
|
||||
<span class="cm"> * :enum:`NGHTTP2_ERR_WOULDBLOCK`. This function calls several</span>
|
||||
<span class="cm"> * callback functions which are passed when initializing the</span>
|
||||
<span class="cm"> * |session|. Here is the simple time chart which tells when each</span>
|
||||
<span class="cm"> * callback is invoked:</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 1. :member:`nghttp2_session_callbacks.recv_callback` is invoked one</span>
|
||||
<span class="cm"> * or more times to receive frame header.</span>
|
||||
<span class="cm"> * 2. If the frame is DATA frame:</span>
|
||||
<span class="cm"> * 1. :type:`nghttp2_recv_callback` is invoked one or more times to</span>
|
||||
<span class="cm"> * receive frame header.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 2. When frame header is received,</span>
|
||||
<span class="cm"> * :type:`nghttp2_on_begin_frame_callback` is invoked.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 3. If the frame is DATA frame:</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 1. :type:`nghttp2_recv_callback` is invoked to receive DATA</span>
|
||||
<span class="cm"> * payload. For each chunk of data,</span>
|
||||
<span class="cm"> * :type:`nghttp2_on_data_chunk_recv_callback` is invoked.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 1. :member:`nghttp2_session_callbacks.recv_callback` is invoked</span>
|
||||
<span class="cm"> * to receive DATA payload. For each chunk of data,</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.on_data_chunk_recv_callback`</span>
|
||||
<span class="cm"> * is invoked.</span>
|
||||
<span class="cm"> * 2. If one DATA frame is completely received,</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.on_frame_recv_callback` is</span>
|
||||
<span class="cm"> * invoked. If the reception of the frame triggers the</span>
|
||||
<span class="cm"> * closure of the stream,</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.on_stream_close_callback`</span>
|
||||
<span class="cm"> * is invoked.</span>
|
||||
<span class="cm"> * :type:`nghttp2_on_frame_recv_callback` is invoked. If the</span>
|
||||
<span class="cm"> * reception of the frame triggers the closure of the stream,</span>
|
||||
<span class="cm"> * :type:`nghttp2_on_stream_close_callback` is invoked.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 3. If the frame is the control frame:</span>
|
||||
<span class="cm"> * 4. If the frame is the control frame:</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 1. :member:`nghttp2_session_callbacks.recv_callback` is invoked</span>
|
||||
<span class="cm"> * one or more times to receive whole frame.</span>
|
||||
<span class="cm"> * 1. :type:`nghttp2_recv_callback` is invoked one or more times to</span>
|
||||
<span class="cm"> * receive whole frame.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 2. If the received frame is valid, then following actions are</span>
|
||||
<span class="cm"> * taken. If the frame is either HEADERS or PUSH_PROMISE,</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.on_begin_headers_callback`</span>
|
||||
<span class="cm"> * is invoked. Then</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.on_header_callback` is</span>
|
||||
<span class="cm"> * invoked for each header name/value pair. After all name/value</span>
|
||||
<span class="cm"> * pairs are emitted successfully,</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.on_frame_recv_callback` is</span>
|
||||
<span class="cm"> * :type:`nghttp2_on_begin_headers_callback` is invoked. Then</span>
|
||||
<span class="cm"> * :type:`nghttp2_on_header_callback` is invoked for each header</span>
|
||||
<span class="cm"> * name/value pair. After all name/value pairs are emitted</span>
|
||||
<span class="cm"> * successfully, :type:`nghttp2_on_frame_recv_callback` is</span>
|
||||
<span class="cm"> * invoked. For other frames,</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.on_frame_recv_callback` is</span>
|
||||
<span class="cm"> * invoked.</span>
|
||||
<span class="cm"> * If the reception of the frame triggers the closure of the</span>
|
||||
<span class="cm"> * stream,</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.on_stream_close_callback`</span>
|
||||
<span class="cm"> * is invoked.</span>
|
||||
<span class="cm"> * :type:`nghttp2_on_frame_recv_callback` is invoked. If the</span>
|
||||
<span class="cm"> * reception of the frame triggers the closure of the stream,</span>
|
||||
<span class="cm"> * :type:`nghttp2_on_stream_close_callback` is invoked.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * 3. If the received frame is unpacked but is interpreted as</span>
|
||||
<span class="cm"> * invalid,</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.on_invalid_frame_recv_callback`</span>
|
||||
<span class="cm"> * is invoked.</span>
|
||||
<span class="cm"> * invalid, :type:`nghttp2_on_invalid_frame_recv_callback` is</span>
|
||||
<span class="cm"> * invoked.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * This function returns 0 if it succeeds, or one of the following</span>
|
||||
<span class="cm"> * negative error codes:</span>
|
||||
|
@ -1995,18 +2170,17 @@
|
|||
<span class="cm"> * |inlen| indicates the number of bytes in the |in|.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * This function behaves like `nghttp2_session_recv()` except that it</span>
|
||||
<span class="cm"> * does not use :member:`nghttp2_session_callbacks.recv_callback` to</span>
|
||||
<span class="cm"> * receive data; the |in| is the only data for the invocation of this</span>
|
||||
<span class="cm"> * function. If all bytes are processed, this function returns. The</span>
|
||||
<span class="cm"> * other callbacks are called in the same way as they are in</span>
|
||||
<span class="cm"> * `nghttp2_session_recv()`.</span>
|
||||
<span class="cm"> * does not use :type:`nghttp2_recv_callback` to receive data; the</span>
|
||||
<span class="cm"> * |in| is the only data for the invocation of this function. If all</span>
|
||||
<span class="cm"> * bytes are processed, this function returns. The other callbacks</span>
|
||||
<span class="cm"> * are called in the same way as they are in `nghttp2_session_recv()`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * In the current implementation, this function always tries to</span>
|
||||
<span class="cm"> * processes all input data unless either an error occurs or</span>
|
||||
<span class="cm"> * :enum:`NGHTTP2_ERR_PAUSE` is returned from</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.on_header_callback` or</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.on_data_chunk_recv_callback`.</span>
|
||||
<span class="cm"> * If :enum:`NGHTTP2_ERR_PAUSE` is used, the return value includes the</span>
|
||||
<span class="cm"> * :type:`nghttp2_on_header_callback` or</span>
|
||||
<span class="cm"> * :type:`nghttp2_on_data_chunk_recv_callback`. If</span>
|
||||
<span class="cm"> * :enum:`NGHTTP2_ERR_PAUSE` is used, the return value includes the</span>
|
||||
<span class="cm"> * number of bytes which was used to produce the data or frame for the</span>
|
||||
<span class="cm"> * callback.</span>
|
||||
<span class="cm"> *</span>
|
||||
|
@ -2171,14 +2345,27 @@
|
|||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Returns the remote window size for a given stream |stream_id|.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * This is the amount of flow-controlled payload (e.g., DATA) that the</span>
|
||||
<span class="cm"> * local endpoint can send without WINDOW_UPDATE.</span>
|
||||
<span class="cm"> * local endpoint can send without stream level WINDOW_UPDATE. There</span>
|
||||
<span class="cm"> * is also connection level flow control, so the effective size of</span>
|
||||
<span class="cm"> * payload that the local endpoint can actually send is</span>
|
||||
<span class="cm"> * min(`nghttp2_session_get_stream_remote_window_size()`,</span>
|
||||
<span class="cm"> * `nghttp2_session_get_remote_window_size()`).</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * This function returns -1 if it fails.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="kt">int32_t</span> <span class="nf">nghttp2_session_get_stream_remote_window_size</span><span class="p">(</span><span class="n">nghttp2_session</span><span class="o">*</span> <span class="n">session</span><span class="p">,</span>
|
||||
<span class="kt">int32_t</span> <span class="n">stream_id</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * @function</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Returns the remote window size for a connection.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * This function always succeeds.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="kt">int32_t</span> <span class="nf">nghttp2_session_get_remote_window_size</span><span class="p">(</span><span class="n">nghttp2_session</span><span class="o">*</span> <span class="n">session</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * @function</span>
|
||||
|
@ -2206,7 +2393,8 @@
|
|||
<span class="cm"> * The last stream ID is the ID of a stream for which</span>
|
||||
<span class="cm"> * :type:`nghttp2_on_frame_recv_callback` was called most recently.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * The |error_code| is the error code of this GOAWAY frame.</span>
|
||||
<span class="cm"> * The |error_code| is the error code of this GOAWAY frame. The</span>
|
||||
<span class="cm"> * pre-defined error code is one of :enum:`nghttp2_error_code`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * After the transmission, both `nghttp2_session_want_read()` and</span>
|
||||
<span class="cm"> * `nghttp2_session_want_write()` return 0.</span>
|
||||
|
@ -2222,7 +2410,7 @@
|
|||
<span class="cm"> * Out of memory.</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="kt">int</span> <span class="nf">nghttp2_session_terminate_session</span><span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_error_code</span> <span class="n">error_code</span><span class="p">);</span>
|
||||
<span class="kt">uint32_t</span> <span class="n">error_code</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * @function</span>
|
||||
|
@ -2241,7 +2429,7 @@
|
|||
<span class="cm"> */</span>
|
||||
<span class="kt">int</span> <span class="nf">nghttp2_session_terminate_session2</span><span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span>
|
||||
<span class="kt">int32_t</span> <span class="n">last_stream_id</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_error_code</span> <span class="n">error_code</span><span class="p">);</span>
|
||||
<span class="kt">uint32_t</span> <span class="n">error_code</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * @function</span>
|
||||
|
@ -2436,8 +2624,8 @@
|
|||
<span class="cm"> * This function returns assigned stream ID if it succeeds. But</span>
|
||||
<span class="cm"> * that stream is not opened yet. The application must not submit</span>
|
||||
<span class="cm"> * frame to that stream ID before</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.before_frame_send_callback` is</span>
|
||||
<span class="cm"> * called for this frame.</span>
|
||||
<span class="cm"> * :type:`nghttp2_before_frame_send_callback` is called for this</span>
|
||||
<span class="cm"> * frame.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="kt">int32_t</span> <span class="nf">nghttp2_submit_request</span><span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span>
|
||||
|
@ -2562,8 +2750,8 @@
|
|||
<span class="cm"> * This function returns assigned stream ID if it succeeds and</span>
|
||||
<span class="cm"> * |stream_id| is -1. But that stream is not opened yet. The</span>
|
||||
<span class="cm"> * application must not submit frame to that stream ID before</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.before_frame_send_callback` is</span>
|
||||
<span class="cm"> * called for this frame.</span>
|
||||
<span class="cm"> * :type:`nghttp2_before_frame_send_callback` is called for this</span>
|
||||
<span class="cm"> * frame.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="kt">int32_t</span> <span class="nf">nghttp2_submit_headers</span><span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="kt">uint8_t</span> <span class="n">flags</span><span class="p">,</span>
|
||||
|
@ -2636,6 +2824,8 @@
|
|||
<span class="cm"> * Submits RST_STREAM frame to cancel/reject the stream |stream_id|</span>
|
||||
<span class="cm"> * with the error code |error_code|.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * The pre-defined error code is one of :enum:`nghttp2_error_code`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * The |flags| is currently ignored and should be</span>
|
||||
<span class="cm"> * :enum:`NGHTTP2_FLAG_NONE`.</span>
|
||||
<span class="cm"> *</span>
|
||||
|
@ -2649,7 +2839,7 @@
|
|||
<span class="cm"> */</span>
|
||||
<span class="kt">int</span> <span class="nf">nghttp2_submit_rst_stream</span><span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="kt">uint8_t</span> <span class="n">flags</span><span class="p">,</span>
|
||||
<span class="kt">int32_t</span> <span class="n">stream_id</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_error_code</span> <span class="n">error_code</span><span class="p">);</span>
|
||||
<span class="kt">uint32_t</span> <span class="n">error_code</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
<span class="cm"> * @function</span>
|
||||
|
@ -2737,8 +2927,8 @@
|
|||
<span class="cm"> * This function returns assigned promised stream ID if it succeeds.</span>
|
||||
<span class="cm"> * But that stream is not opened yet. The application must not</span>
|
||||
<span class="cm"> * submit frame to that stream ID before</span>
|
||||
<span class="cm"> * :member:`nghttp2_session_callbacks.before_frame_send_callback` is</span>
|
||||
<span class="cm"> * called for this frame.</span>
|
||||
<span class="cm"> * :type:`nghttp2_before_frame_send_callback` is called for this</span>
|
||||
<span class="cm"> * frame.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="kt">int32_t</span> <span class="nf">nghttp2_submit_push_promise</span><span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="kt">uint8_t</span> <span class="n">flags</span><span class="p">,</span>
|
||||
|
@ -2776,6 +2966,8 @@
|
|||
<span class="cm"> * Submits GOAWAY frame with the last stream ID |last_stream_id| and</span>
|
||||
<span class="cm"> * the error code |error_code|.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * The pre-defined error code is one of :enum:`nghttp2_error_code`.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * The |flags| is currently ignored and should be</span>
|
||||
<span class="cm"> * :enum:`NGHTTP2_FLAG_NONE`.</span>
|
||||
<span class="cm"> *</span>
|
||||
|
@ -2802,7 +2994,7 @@
|
|||
<span class="cm"> */</span>
|
||||
<span class="kt">int</span> <span class="nf">nghttp2_submit_goaway</span><span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="kt">uint8_t</span> <span class="n">flags</span><span class="p">,</span>
|
||||
<span class="kt">int32_t</span> <span class="n">last_stream_id</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_error_code</span> <span class="n">error_code</span><span class="p">,</span>
|
||||
<span class="kt">uint32_t</span> <span class="n">error_code</span><span class="p">,</span>
|
||||
<span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span><span class="n">opaque_data</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">opaque_data_len</span><span class="p">);</span>
|
||||
|
||||
<span class="cm">/**</span>
|
||||
|
|
BIN
objects.inv
BIN
objects.inv
Binary file not shown.
|
@ -280,7 +280,7 @@ required:</p>
|
|||
<p>To enable SPDY protocol in the application program <tt class="docutils literal"><span class="pre">nghttpx</span></tt> and
|
||||
<tt class="docutils literal"><span class="pre">h2load</span></tt>, the following package is required:</p>
|
||||
<ul class="simple">
|
||||
<li>spdylay >= 1.2.3</li>
|
||||
<li>spdylay >= 1.3.0</li>
|
||||
</ul>
|
||||
<p>To enable <tt class="docutils literal"><span class="pre">-a</span></tt> option (getting linked assets from the downloaded
|
||||
resource) in <tt class="docutils literal"><span class="pre">nghttp</span></tt>, the following package is required:</p>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -342,15 +342,30 @@ finished successfully. We first initialize nghttp2 session object in
|
|||
<tt class="docutils literal"><span class="pre">initialize_nghttp2_session()</span></tt> function:</p>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="k">static</span> <span class="kt">void</span> <span class="nf">initialize_nghttp2_session</span><span class="p">(</span><span class="n">http2_session_data</span> <span class="o">*</span><span class="n">session_data</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
<span class="n">nghttp2_session_callbacks</span> <span class="n">callbacks</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">};</span>
|
||||
<span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">callbacks</span><span class="p">;</span>
|
||||
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">send_callback</span> <span class="o">=</span> <span class="n">send_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_frame_recv_callback</span> <span class="o">=</span> <span class="n">on_frame_recv_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_data_chunk_recv_callback</span> <span class="o">=</span> <span class="n">on_data_chunk_recv_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_stream_close_callback</span> <span class="o">=</span> <span class="n">on_stream_close_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_header_callback</span> <span class="o">=</span> <span class="n">on_header_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_begin_headers_callback</span> <span class="o">=</span> <span class="n">on_begin_headers_callback</span><span class="p">;</span>
|
||||
<span class="n">nghttp2_session_client_new</span><span class="p">(</span><span class="o">&</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="o">&</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">session_data</span><span class="p">);</span>
|
||||
<span class="n">nghttp2_session_callbacks_new</span><span class="p">(</span><span class="o">&</span><span class="n">callbacks</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_send_callback</span><span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">send_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_frame_recv_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_frame_recv_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_data_chunk_recv_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_data_chunk_recv_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_stream_close_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_stream_close_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_header_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_header_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_begin_headers_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_begin_headers_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_client_new</span><span class="p">(</span><span class="o">&</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="n">callbacks</span><span class="p">,</span> <span class="n">session_data</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_del</span><span class="p">(</span><span class="n">callbacks</span><span class="p">);</span>
|
||||
<span class="p">}</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
|
@ -474,11 +489,9 @@ frames. The <tt class="docutils literal"><span class="pre">session_send()</span>
|
|||
</pre></div>
|
||||
</div>
|
||||
<p>The <a class="reference internal" href="apiref.html#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a> function serializes the frame into wire
|
||||
format and call <a class="reference internal" href="apiref.html#c.nghttp2_session_callbacks.send_callback" title="nghttp2_session_callbacks.send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.send_callback</span></tt></a> with
|
||||
it. We set <tt class="docutils literal"><span class="pre">send_callback()</span></tt> function to
|
||||
<a class="reference internal" href="apiref.html#c.nghttp2_session_callbacks.send_callback" title="nghttp2_session_callbacks.send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.send_callback</span></tt></a> in
|
||||
<tt class="docutils literal"><span class="pre">initialize_nghttp2_session()</span></tt> function described earlier. It is
|
||||
defined as follows:</p>
|
||||
format and call <tt class="docutils literal"><span class="pre">send_callback()</span></tt> function of type
|
||||
<a class="reference internal" href="apiref.html#c.nghttp2_send_callback" title="nghttp2_send_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_send_callback</span></tt></a>. The <tt class="docutils literal"><span class="pre">send_callback()</span></tt> is defined as
|
||||
follows:</p>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="k">static</span> <span class="kt">ssize_t</span> <span class="nf">send_callback</span><span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span>
|
||||
<span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span><span class="n">data</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">length</span><span class="p">,</span>
|
||||
<span class="kt">int</span> <span class="n">flags</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">)</span>
|
||||
|
@ -494,15 +507,14 @@ defined as follows:</p>
|
|||
data to the bufferevent object. Note that <a class="reference internal" href="apiref.html#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a>
|
||||
continues to write all frames queued so far. If we were writing the
|
||||
data to the non-blocking socket directly using <tt class="docutils literal"><span class="pre">write()</span></tt> system call
|
||||
in the <a class="reference internal" href="apiref.html#c.nghttp2_session_callbacks.send_callback" title="nghttp2_session_callbacks.send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.send_callback</span></tt></a>, we will
|
||||
surely get <tt class="docutils literal"><span class="pre">EAGAIN</span></tt> or <tt class="docutils literal"><span class="pre">EWOULDBLOCK</span></tt> since the socket has limited
|
||||
send buffer. If that happens, we can return
|
||||
<a class="reference internal" href="apiref.html#c.NGHTTP2_ERR_WOULDBLOCK" title="NGHTTP2_ERR_WOULDBLOCK"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_WOULDBLOCK</span></tt></a> to signal the nghttp2 library to stop
|
||||
sending further data. But writing to the bufferevent, we have to
|
||||
regulate the amount data to be buffered by ourselves to avoid possible
|
||||
huge memory consumption. In this example client, we do not limit
|
||||
anything. To see how to regulate the amount of buffered data, see the
|
||||
<tt class="docutils literal"><span class="pre">send_callback()</span></tt> in the server tutorial.</p>
|
||||
in the <tt class="docutils literal"><span class="pre">send_callback()</span></tt>, we will surely get <tt class="docutils literal"><span class="pre">EAGAIN</span></tt> or
|
||||
<tt class="docutils literal"><span class="pre">EWOULDBLOCK</span></tt> since the socket has limited send buffer. If that
|
||||
happens, we can return <a class="reference internal" href="apiref.html#c.NGHTTP2_ERR_WOULDBLOCK" title="NGHTTP2_ERR_WOULDBLOCK"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_WOULDBLOCK</span></tt></a> to signal the
|
||||
nghttp2 library to stop sending further data. But writing to the
|
||||
bufferevent, we have to regulate the amount data to be buffered by
|
||||
ourselves to avoid possible huge memory consumption. In this example
|
||||
client, we do not limit anything. To see how to regulate the amount of
|
||||
buffered data, see the <tt class="docutils literal"><span class="pre">send_callback()</span></tt> in the server tutorial.</p>
|
||||
<p>The third bufferevent callback is <tt class="docutils literal"><span class="pre">writecb()</span></tt>, which is invoked when
|
||||
all data written in the bufferevent output buffer have been sent:</p>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="k">static</span> <span class="kt">void</span> <span class="nf">writecb</span><span class="p">(</span><span class="k">struct</span> <span class="n">bufferevent</span> <span class="o">*</span><span class="n">bev</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">ptr</span><span class="p">)</span>
|
||||
|
@ -961,17 +973,30 @@ here.</p>
|
|||
|
||||
<span class="k">static</span> <span class="kt">void</span> <span class="nf">initialize_nghttp2_session</span><span class="p">(</span><span class="n">http2_session_data</span> <span class="o">*</span><span class="n">session_data</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
<span class="n">nghttp2_session_callbacks</span> <span class="n">callbacks</span><span class="p">;</span>
|
||||
<span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">callbacks</span><span class="p">;</span>
|
||||
|
||||
<span class="n">memset</span><span class="p">(</span><span class="o">&</span><span class="n">callbacks</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">callbacks</span><span class="p">));</span>
|
||||
<span class="n">nghttp2_session_callbacks_new</span><span class="p">(</span><span class="o">&</span><span class="n">callbacks</span><span class="p">);</span>
|
||||
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">send_callback</span> <span class="o">=</span> <span class="n">send_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_frame_recv_callback</span> <span class="o">=</span> <span class="n">on_frame_recv_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_data_chunk_recv_callback</span> <span class="o">=</span> <span class="n">on_data_chunk_recv_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_stream_close_callback</span> <span class="o">=</span> <span class="n">on_stream_close_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_header_callback</span> <span class="o">=</span> <span class="n">on_header_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_begin_headers_callback</span> <span class="o">=</span> <span class="n">on_begin_headers_callback</span><span class="p">;</span>
|
||||
<span class="n">nghttp2_session_client_new</span><span class="p">(</span><span class="o">&</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="o">&</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">session_data</span><span class="p">);</span>
|
||||
<span class="n">nghttp2_session_callbacks_set_send_callback</span><span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">send_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_frame_recv_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_frame_recv_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_data_chunk_recv_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_data_chunk_recv_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_stream_close_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_stream_close_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_header_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_header_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_begin_headers_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_begin_headers_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_client_new</span><span class="p">(</span><span class="o">&</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="n">callbacks</span><span class="p">,</span> <span class="n">session_data</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_del</span><span class="p">(</span><span class="n">callbacks</span><span class="p">);</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="k">static</span> <span class="kt">void</span> <span class="nf">send_client_connection_header</span><span class="p">(</span><span class="n">http2_session_data</span> <span class="o">*</span><span class="n">session_data</span><span class="p">)</span>
|
||||
|
|
|
@ -412,14 +412,27 @@ HTTP/2 communication. These two functions are described later.</p>
|
|||
<tt class="docutils literal"><span class="pre">initialize_nghttp2_session()</span></tt>:</p>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="k">static</span> <span class="kt">void</span> <span class="nf">initialize_nghttp2_session</span><span class="p">(</span><span class="n">http2_session_data</span> <span class="o">*</span><span class="n">session_data</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
<span class="n">nghttp2_session_callbacks</span> <span class="n">callbacks</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">};</span>
|
||||
<span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">callbacks</span><span class="p">;</span>
|
||||
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">send_callback</span> <span class="o">=</span> <span class="n">send_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_frame_recv_callback</span> <span class="o">=</span> <span class="n">on_frame_recv_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_stream_close_callback</span> <span class="o">=</span> <span class="n">on_stream_close_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_header_callback</span> <span class="o">=</span> <span class="n">on_header_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_begin_headers_callback</span> <span class="o">=</span> <span class="n">on_begin_headers_callback</span><span class="p">;</span>
|
||||
<span class="n">nghttp2_session_server_new</span><span class="p">(</span><span class="o">&</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="o">&</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">session_data</span><span class="p">);</span>
|
||||
<span class="n">nghttp2_session_callbacks_new</span><span class="p">(</span><span class="o">&</span><span class="n">callbacks</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_send_callback</span><span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">send_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_frame_recv_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_frame_recv_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_stream_close_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_stream_close_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_header_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_header_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_begin_headers_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_begin_headers_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_server_new</span><span class="p">(</span><span class="o">&</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="n">callbacks</span><span class="p">,</span> <span class="n">session_data</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_del</span><span class="p">(</span><span class="n">callbacks</span><span class="p">);</span>
|
||||
<span class="p">}</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
|
@ -499,11 +512,9 @@ frames. The <tt class="docutils literal"><span class="pre">session_send()</span>
|
|||
</pre></div>
|
||||
</div>
|
||||
<p>The <a class="reference internal" href="apiref.html#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a> function serializes the frame into wire
|
||||
format and calls <a class="reference internal" href="apiref.html#c.nghttp2_session_callbacks.send_callback" title="nghttp2_session_callbacks.send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.send_callback</span></tt></a> with
|
||||
it. We set the <tt class="docutils literal"><span class="pre">send_callback()</span></tt> function to
|
||||
<a class="reference internal" href="apiref.html#c.nghttp2_session_callbacks.send_callback" title="nghttp2_session_callbacks.send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.send_callback</span></tt></a> in
|
||||
<tt class="docutils literal"><span class="pre">initialize_nghttp2_session()</span></tt> function described earlier. It is
|
||||
defined as follows:</p>
|
||||
format and calls <tt class="docutils literal"><span class="pre">send_callback()</span></tt> of type
|
||||
<a class="reference internal" href="apiref.html#c.nghttp2_send_callback" title="nghttp2_send_callback"><tt class="xref c c-type docutils literal"><span class="pre">nghttp2_send_callback</span></tt></a>. The <tt class="docutils literal"><span class="pre">send_callback()</span></tt> is defined as
|
||||
follows:</p>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="k">static</span> <span class="kt">ssize_t</span> <span class="nf">send_callback</span><span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span>
|
||||
<span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span><span class="n">data</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">length</span><span class="p">,</span>
|
||||
<span class="kt">int</span> <span class="n">flags</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">)</span>
|
||||
|
@ -520,20 +531,20 @@ defined as follows:</p>
|
|||
<span class="p">}</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Since we use bufferevent to abstract network I/O, we just write the data to
|
||||
the bufferevent object. Note that <a class="reference internal" href="apiref.html#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a> continues to write
|
||||
all frames queued so far. If we were writing the data to a non-blocking socket
|
||||
directly using <tt class="docutils literal"><span class="pre">write()</span></tt> system call in the
|
||||
<a class="reference internal" href="apiref.html#c.nghttp2_session_callbacks.send_callback" title="nghttp2_session_callbacks.send_callback"><tt class="xref c c-member docutils literal"><span class="pre">nghttp2_session_callbacks.send_callback</span></tt></a>, we would surely get
|
||||
<tt class="docutils literal"><span class="pre">EAGAIN</span></tt> or <tt class="docutils literal"><span class="pre">EWOULDBLOCK</span></tt> back since the socket has limited send
|
||||
buffer. If that happens, we can return <a class="reference internal" href="apiref.html#c.NGHTTP2_ERR_WOULDBLOCK" title="NGHTTP2_ERR_WOULDBLOCK"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_WOULDBLOCK</span></tt></a> to
|
||||
signal the nghttp2 library to stop sending further data. But when writing to
|
||||
the bufferevent, we have to regulate the amount data to get buffered ourselves
|
||||
to avoid using huge amounts of memory. To achieve this, we check the size of
|
||||
the output buffer and if it reaches more than or equal to
|
||||
<tt class="docutils literal"><span class="pre">OUTPUT_WOULDBLOCK_THRESHOLD</span></tt> bytes, we stop writing data and return
|
||||
<a class="reference internal" href="apiref.html#c.NGHTTP2_ERR_WOULDBLOCK" title="NGHTTP2_ERR_WOULDBLOCK"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_WOULDBLOCK</span></tt></a> to tell the library to stop calling
|
||||
send_callback.</p>
|
||||
<p>Since we use bufferevent to abstract network I/O, we just write the
|
||||
data to the bufferevent object. Note that <a class="reference internal" href="apiref.html#c.nghttp2_session_send" title="nghttp2_session_send"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_send()</span></tt></a>
|
||||
continues to write all frames queued so far. If we were writing the
|
||||
data to a non-blocking socket directly using <tt class="docutils literal"><span class="pre">write()</span></tt> system call
|
||||
in the <tt class="docutils literal"><span class="pre">send_callback()</span></tt>, we would surely get <tt class="docutils literal"><span class="pre">EAGAIN</span></tt> or
|
||||
<tt class="docutils literal"><span class="pre">EWOULDBLOCK</span></tt> back since the socket has limited send buffer. If that
|
||||
happens, we can return <a class="reference internal" href="apiref.html#c.NGHTTP2_ERR_WOULDBLOCK" title="NGHTTP2_ERR_WOULDBLOCK"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_WOULDBLOCK</span></tt></a> to signal the
|
||||
nghttp2 library to stop sending further data. But when writing to the
|
||||
bufferevent, we have to regulate the amount data to get buffered
|
||||
ourselves to avoid using huge amounts of memory. To achieve this, we
|
||||
check the size of the output buffer and if it reaches more than or
|
||||
equal to <tt class="docutils literal"><span class="pre">OUTPUT_WOULDBLOCK_THRESHOLD</span></tt> bytes, we stop writing data
|
||||
and return <a class="reference internal" href="apiref.html#c.NGHTTP2_ERR_WOULDBLOCK" title="NGHTTP2_ERR_WOULDBLOCK"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_WOULDBLOCK</span></tt></a> to tell the library to stop
|
||||
calling send_callback.</p>
|
||||
<p>The next bufferevent callback is <tt class="docutils literal"><span class="pre">readcb()</span></tt>, which is invoked when
|
||||
data is available to read in the bufferevent input buffer:</p>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="k">static</span> <span class="kt">void</span> <span class="nf">readcb</span><span class="p">(</span><span class="k">struct</span> <span class="n">bufferevent</span> <span class="o">*</span><span class="n">bev</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">ptr</span><span class="p">)</span>
|
||||
|
@ -1315,16 +1326,27 @@ is about to close and we no longer use that object.</p>
|
|||
|
||||
<span class="k">static</span> <span class="kt">void</span> <span class="nf">initialize_nghttp2_session</span><span class="p">(</span><span class="n">http2_session_data</span> <span class="o">*</span><span class="n">session_data</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
<span class="n">nghttp2_session_callbacks</span> <span class="n">callbacks</span><span class="p">;</span>
|
||||
<span class="n">nghttp2_session_callbacks</span> <span class="o">*</span><span class="n">callbacks</span><span class="p">;</span>
|
||||
|
||||
<span class="n">memset</span><span class="p">(</span><span class="o">&</span><span class="n">callbacks</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">callbacks</span><span class="p">));</span>
|
||||
<span class="n">nghttp2_session_callbacks_new</span><span class="p">(</span><span class="o">&</span><span class="n">callbacks</span><span class="p">);</span>
|
||||
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">send_callback</span> <span class="o">=</span> <span class="n">send_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_frame_recv_callback</span> <span class="o">=</span> <span class="n">on_frame_recv_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_stream_close_callback</span> <span class="o">=</span> <span class="n">on_stream_close_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_header_callback</span> <span class="o">=</span> <span class="n">on_header_callback</span><span class="p">;</span>
|
||||
<span class="n">callbacks</span><span class="p">.</span><span class="n">on_begin_headers_callback</span> <span class="o">=</span> <span class="n">on_begin_headers_callback</span><span class="p">;</span>
|
||||
<span class="n">nghttp2_session_server_new</span><span class="p">(</span><span class="o">&</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="o">&</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">session_data</span><span class="p">);</span>
|
||||
<span class="n">nghttp2_session_callbacks_set_send_callback</span><span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">send_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_frame_recv_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_frame_recv_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_stream_close_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_stream_close_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_header_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_header_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_set_on_begin_headers_callback</span>
|
||||
<span class="p">(</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">on_begin_headers_callback</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_server_new</span><span class="p">(</span><span class="o">&</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="n">callbacks</span><span class="p">,</span> <span class="n">session_data</span><span class="p">);</span>
|
||||
|
||||
<span class="n">nghttp2_session_callbacks_del</span><span class="p">(</span><span class="n">callbacks</span><span class="p">);</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="cm">/* Send HTTP/2 client connection header, which includes 24 bytes</span>
|
||||
|
|
Loading…
Reference in New Issue