nghttp2/python
Tatsuhiro Tsujikawa 5c88e92e96 python: Add python script to check hpack-test-case json files
See https://github.com/Jxck/hpack-test-case for the json file
format.
2014-01-05 23:40:04 +09:00
..
Makefile.am python: Remove unnecessary variables 2013-12-18 21:17:32 +09:00
README.rst Update README.rst in python dir 2013-12-20 01:35:59 +09:00
cnghttp2.pxd python: Handle name/value is NULL but its length is positive 2013-12-21 23:02:48 +09:00
hpackcheck.py python: Add python script to check hpack-test-case json files 2014-01-05 23:40:04 +09:00
nghttp2.pyx python: Handle name/value is NULL but its length is positive 2013-12-21 23:02:48 +09:00
setup.py python: Add experimental python extension module 2013-12-14 23:54:09 +09:00

README.rst

nghttp2 Python C extension module
=================================

This directory contains nghttp2 Python C extension module.  Currently,
header compressor and decompressor are implemented in extension using
cython.

This is experimental and adds some dependencies which is a bit hard to
check, so this extension module does not built with usual ``make`` in
the top directory. Instead, a user has to run ``make build_ext`` in
this directory.

The build extension module is called ``nghttp2``.

The module refers to the libnghttp2.so. If nghttp2 is installed using
``make install``, then importing nghttp2 module should work.  If a
user does not want to install nghttp2, then use ``LD_LIBRARY_PATH``
pointing to the location of libnghttp2.so, which is usually in
``lib/.libs``. If a user also does not want to install nghttp2 module,
use PYTHONPATH to point the location of extension module. This depends
on the architecture and Python version. For example, x86_64
architecture and Python 2.7 series, a module will be located at
``build/lib.linux-x86_64-2.7``.

Header compression
------------------

The following example code illustrates basic usage of compressor and
decompressor::

    import binascii
    import nghttp2

    deflater = nghttp2.HDDeflater(nghttp2.HD_SIDE_REQUEST)
    inflater = nghttp2.HDInflater(nghttp2.HD_SIDE_REQUEST)

    data = deflater.deflate([(b'foo', b'bar'),
			     (b'baz', b'buz')])
    print(binascii.b2a_hex(data))

    hdrs = inflater.inflate(data)
    print(hdrs)