Update doc
This commit is contained in:
parent
0f347d07b0
commit
2f2b071353
41
apiref.html
41
apiref.html
|
@ -3144,6 +3144,47 @@ or one of the following negative error codes:</p>
|
|||
<dt><a class="reference internal" href="#c.NGHTTP2_ERR_HEADER_COMP" title="NGHTTP2_ERR_HEADER_COMP"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_HEADER_COMP</span></tt></a></dt>
|
||||
<dd>Inflation process has failed.</dd>
|
||||
</dl>
|
||||
<p>Example follows:</p>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">inflate_header_block</span><span class="p">(</span><span class="n">nghttp2_hd_inflater</span> <span class="o">*</span><span class="n">hd_inflater</span><span class="p">,</span>
|
||||
<span class="kt">uint8_t</span> <span class="o">*</span><span class="n">in</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">inlen</span><span class="p">,</span> <span class="kt">int</span> <span class="n">final</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
<span class="kt">int</span> <span class="n">rv</span><span class="p">;</span>
|
||||
|
||||
<span class="k">for</span><span class="p">(;;)</span> <span class="p">{</span>
|
||||
<span class="n">nghttp2_nv</span> <span class="n">nv</span><span class="p">;</span>
|
||||
<span class="kt">int</span> <span class="n">inflate_flags</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
||||
|
||||
<span class="n">rv</span> <span class="o">=</span> <span class="n">nghttp2_hd_inflate_hd</span><span class="p">(</span><span class="n">hd_inflater</span><span class="p">,</span> <span class="o">&</span><span class="n">nv</span><span class="p">,</span> <span class="o">&</span><span class="n">inflate_flags</span><span class="p">,</span>
|
||||
<span class="n">in</span><span class="p">,</span> <span class="n">inlen</span><span class="p">,</span> <span class="n">final</span><span class="p">);</span>
|
||||
|
||||
<span class="k">if</span><span class="p">(</span><span class="n">rv</span> <span class="o"><</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">"inflate failed with error code %d"</span><span class="p">,</span> <span class="n">rv</span><span class="p">);</span>
|
||||
<span class="k">return</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="n">in</span> <span class="o">+=</span> <span class="n">rv</span><span class="p">;</span>
|
||||
<span class="n">inlen</span> <span class="o">-=</span> <span class="n">rv</span><span class="p">;</span>
|
||||
|
||||
<span class="k">if</span><span class="p">(</span><span class="n">inflate_flags</span> <span class="o">&</span> <span class="n">NGHTTP2_HD_INFLATE_EMIT</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="n">fwrite</span><span class="p">(</span><span class="n">nv</span><span class="p">.</span><span class="n">name</span><span class="p">,</span> <span class="n">nv</span><span class="p">.</span><span class="n">namelen</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">stderr</span><span class="p">);</span>
|
||||
<span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">": "</span><span class="p">);</span>
|
||||
<span class="n">fwrite</span><span class="p">(</span><span class="n">nv</span><span class="p">.</span><span class="n">value</span><span class="p">,</span> <span class="n">nv</span><span class="p">.</span><span class="n">valuelen</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">stderr</span><span class="p">);</span>
|
||||
<span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">"</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>
|
||||
<span class="p">}</span>
|
||||
<span class="k">if</span><span class="p">(</span><span class="n">inflate_flags</span> <span class="o">&</span> <span class="n">NGHTTP2_HD_INFLATE_FINAL</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="n">nghttp2_hd_inflate_end_headers</span><span class="p">(</span><span class="n">hd_inflater</span><span class="p">);</span>
|
||||
<span class="k">break</span><span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
<span class="k">if</span><span class="p">((</span><span class="n">inflate_flags</span> <span class="o">&</span> <span class="n">NGHTTP2_HD_INFLATE_EMIT</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span> <span class="o">&&</span>
|
||||
<span class="n">inlen</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="k">break</span><span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
|
|
|
@ -3104,6 +3104,48 @@
|
|||
<span class="cm"> * Out of memory.</span>
|
||||
<span class="cm"> * :enum:`NGHTTP2_ERR_HEADER_COMP`</span>
|
||||
<span class="cm"> * Inflation process has failed.</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Example follows::</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * int inflate_header_block(nghttp2_hd_inflater *hd_inflater,</span>
|
||||
<span class="cm"> * uint8_t *in, size_t inlen, int final)</span>
|
||||
<span class="cm"> * {</span>
|
||||
<span class="cm"> * int rv;</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * for(;;) {</span>
|
||||
<span class="cm"> * nghttp2_nv nv;</span>
|
||||
<span class="cm"> * int inflate_flags = 0;</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * rv = nghttp2_hd_inflate_hd(hd_inflater, &nv, &inflate_flags,</span>
|
||||
<span class="cm"> * in, inlen, final);</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * if(rv < 0) {</span>
|
||||
<span class="cm"> * fprintf(stderr, "inflate failed with error code %d", rv);</span>
|
||||
<span class="cm"> * return -1;</span>
|
||||
<span class="cm"> * }</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * in += rv;</span>
|
||||
<span class="cm"> * inlen -= rv;</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * if(inflate_flags & NGHTTP2_HD_INFLATE_EMIT) {</span>
|
||||
<span class="cm"> * fwrite(nv.name, nv.namelen, 1, stderr);</span>
|
||||
<span class="cm"> * fprintf(stderr, ": ");</span>
|
||||
<span class="cm"> * fwrite(nv.value, nv.valuelen, 1, stderr);</span>
|
||||
<span class="cm"> * fprintf(stderr, "\n");</span>
|
||||
<span class="cm"> * }</span>
|
||||
<span class="cm"> * if(inflate_flags & NGHTTP2_HD_INFLATE_FINAL) {</span>
|
||||
<span class="cm"> * nghttp2_hd_inflate_end_headers(hd_inflater);</span>
|
||||
<span class="cm"> * break;</span>
|
||||
<span class="cm"> * }</span>
|
||||
<span class="cm"> * if((inflate_flags & NGHTTP2_HD_INFLATE_EMIT) == 0 &&</span>
|
||||
<span class="cm"> * inlen == 0) {</span>
|
||||
<span class="cm"> * break;</span>
|
||||
<span class="cm"> * }</span>
|
||||
<span class="cm"> * }</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * return 0;</span>
|
||||
<span class="cm"> * }</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> */</span>
|
||||
<span class="kt">ssize_t</span> <span class="nf">nghttp2_hd_inflate_hd</span><span class="p">(</span><span class="n">nghttp2_hd_inflater</span> <span class="o">*</span><span class="n">inflater</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_nv</span> <span class="o">*</span><span class="n">nv_out</span><span class="p">,</span> <span class="kt">int</span> <span class="o">*</span><span class="n">inflate_flags</span><span class="p">,</span>
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue