Update doc

This commit is contained in:
Tatsuhiro Tsujikawa 2014-01-11 02:03:15 +09:00
parent 6289910a43
commit d8f5253634
3 changed files with 11 additions and 10 deletions

Binary file not shown.

View File

@ -888,18 +888,19 @@ variable as an argument to configure script (e.g., <tt class="docutils literal">
<h3>Example<a class="headerlink" href="#example" title="Permalink to this headline"></a></h3> <h3>Example<a class="headerlink" href="#example" title="Permalink to this headline"></a></h3>
<p>The following example code illustrates basic usage of HPACK compressor <p>The following example code illustrates basic usage of HPACK compressor
and decompressor in Python:</p> and decompressor in Python:</p>
<div class="highlight-c"><pre>import binascii <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">binascii</span>
import nghttp2 <span class="kn">import</span> <span class="nn">nghttp2</span>
deflater = nghttp2.HDDeflater(nghttp2.HD_SIDE_REQUEST) <span class="n">deflater</span> <span class="o">=</span> <span class="n">nghttp2</span><span class="o">.</span><span class="n">HDDeflater</span><span class="p">(</span><span class="n">nghttp2</span><span class="o">.</span><span class="n">HD_SIDE_REQUEST</span><span class="p">)</span>
inflater = nghttp2.HDInflater(nghttp2.HD_SIDE_REQUEST) <span class="n">inflater</span> <span class="o">=</span> <span class="n">nghttp2</span><span class="o">.</span><span class="n">HDInflater</span><span class="p">(</span><span class="n">nghttp2</span><span class="o">.</span><span class="n">HD_SIDE_REQUEST</span><span class="p">)</span>
data = deflater.deflate([(b'foo', b'bar'), <span class="n">data</span> <span class="o">=</span> <span class="n">deflater</span><span class="o">.</span><span class="n">deflate</span><span class="p">([(</span><span class="n">b</span><span class="s">&#39;foo&#39;</span><span class="p">,</span> <span class="n">b</span><span class="s">&#39;bar&#39;</span><span class="p">),</span>
(b'baz', b'buz')]) <span class="p">(</span><span class="n">b</span><span class="s">&#39;baz&#39;</span><span class="p">,</span> <span class="n">b</span><span class="s">&#39;buz&#39;</span><span class="p">)])</span>
print(binascii.b2a_hex(data)) <span class="k">print</span><span class="p">(</span><span class="n">binascii</span><span class="o">.</span><span class="n">b2a_hex</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
hdrs = inflater.inflate(data) <span class="n">hdrs</span> <span class="o">=</span> <span class="n">inflater</span><span class="o">.</span><span class="n">inflate</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
print(hdrs)</pre> <span class="k">print</span><span class="p">(</span><span class="n">hdrs</span><span class="p">)</span>
</pre></div>
</div> </div>
</div> </div>
</div> </div>

File diff suppressed because one or more lines are too long