2013-07-28 14:26:41 +02:00
2013-12-06 17:29:39 +01:00
<!DOCTYPE html>
<!-- [if IE 8]><html class="no - js lt - ie9" lang="en" > <![endif] -->
<!-- [if gt IE 8]><! --> < html class = "no-js" lang = "en" > <!-- <![endif] -->
< head >
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
2014-02-05 15:22:31 +01:00
< title > nghttp2 - HTTP/2.0 C Library — nghttp2 0.4.0-DEV documentation< / title >
2013-12-06 17:29:39 +01:00
< link href = 'https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel = 'stylesheet' type = 'text/css' >
2013-07-28 14:26:41 +02:00
< script type = "text/javascript" >
var DOCUMENTATION_OPTIONS = {
2013-12-06 17:29:39 +01:00
URL_ROOT:'',
2014-02-05 15:22:31 +01:00
VERSION:'0.4.0-DEV',
2013-12-06 17:29:39 +01:00
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
2013-07-28 14:26:41 +02:00
HAS_SOURCE: true
};
< / script >
2013-12-06 17:29:39 +01:00
< script type = "text/javascript" src = "_static/jquery.js" > < / script >
< script type = "text/javascript" src = "_static/underscore.js" > < / script >
< script type = "text/javascript" src = "_static/doctools.js" > < / script >
< link rel = "stylesheet" href = "_static/css/theme.css" type = "text/css" / >
< script type = "text/javascript" src = "_static/js/theme.js" > < / script >
2014-02-02 10:36:57 +01:00
< script type = "text/javascript" >
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
< / script >
2014-02-05 15:22:31 +01:00
< link rel = "top" title = "nghttp2 0.4.0-DEV documentation" href = "index.html" / >
2013-12-24 16:31:37 +01:00
< link rel = "next" title = "Tutorial: HTTP/2.0 client" href = "tutorial-client.html" / >
2013-12-06 17:29:39 +01:00
< link rel = "prev" title = "nghttp2 - HTTP/2.0 C Library" href = "index.html" / >
2014-02-02 10:36:57 +01:00
< script src = "https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js" > < / script >
2013-12-06 17:29:39 +01:00
< / head >
2014-02-02 10:36:57 +01:00
< body class = "wy-body-for-nav" role = "document" >
2013-12-06 17:29:39 +01:00
< div class = "wy-grid-for-nav" >
< nav data-toggle = "wy-nav-shift" class = "wy-nav-side" >
< div class = "wy-side-nav-search" >
2014-02-02 10:36:57 +01:00
< a href = "index.html" class = "fa fa-home" > nghttp2< / a >
< div role = "search" >
< form id = "rtd-search-form" class = "wy-form" action = "search.html" method = "get" >
< input type = "text" name = "q" placeholder = "Search docs" / >
< input type = "hidden" name = "check_keywords" value = "yes" / >
< input type = "hidden" name = "area" value = "default" / >
< / form >
< / div >
2013-12-06 17:29:39 +01:00
< / div >
2014-02-02 10:36:57 +01:00
< div class = "wy-menu wy-menu-vertical" data-spy = "affix" role = "navigation" aria-label = "main navigation" >
2013-12-06 17:29:39 +01:00
< ul class = "current" >
< li class = "toctree-l1 current" > < a class = "current reference internal" href = "" > nghttp2 - HTTP/2.0 C Library< / a > < ul >
< li class = "toctree-l2" > < a class = "reference internal" href = "#development-status" > Development Status< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "#public-test-server" > Public Test Server< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "#requirements" > Requirements< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "#build-from-git" > Build from git< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "#building-documentation" > Building documentation< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "#client-server-and-proxy-programs" > Client, Server and Proxy programs< / a > < / li >
2014-01-10 17:07:30 +01:00
< li class = "toctree-l2" > < a class = "reference internal" href = "#hpack-tools" > HPACK tools< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "#python-bindings" > Python bindings< / a > < / li >
2013-12-06 17:29:39 +01:00
< / ul >
< / li >
2013-12-26 15:39:18 +01:00
< li class = "toctree-l1" > < a class = "reference internal" href = "tutorial-client.html" > Tutorial: HTTP/2.0 client< / a > < ul >
< li class = "toctree-l2" > < a class = "reference internal" href = "tutorial-client.html#libevent-client-c" > libevent-client.c< / a > < / li >
< / ul >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "tutorial-server.html" > Tutorial: HTTP/2.0 server< / a > < ul >
< li class = "toctree-l2" > < a class = "reference internal" href = "tutorial-server.html#libevent-server-c" > libevent-server.c< / a > < / li >
< / ul >
< / li >
2013-12-06 17:29:39 +01:00
< li class = "toctree-l1" > < a class = "reference internal" href = "apiref.html" > API Reference< / a > < ul >
< li class = "toctree-l2" > < a class = "reference internal" href = "apiref.html#includes" > Includes< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "apiref.html#remarks" > Remarks< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "apiref.html#macros" > Macros< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "apiref.html#enums" > Enums< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "apiref.html#types-structs-unions-and-typedefs" > Types (structs, unions and typedefs)< / a > < / li >
< li class = "toctree-l2" > < a class = "reference internal" href = "apiref.html#functions" > Functions< / a > < / li >
< / ul >
< / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "nghttp2.h.html" > nghttp2.h< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "nghttp2ver.h.html" > nghttp2ver.h< / a > < / li >
2013-12-07 06:58:21 +01:00
< li class = "toctree-l1" > < a class = "reference external" href = "https://github.com/tatsuhiro-t/nghttp2" > Source< / a > < / li >
< li class = "toctree-l1" > < a class = "reference external" href = "https://github.com/tatsuhiro-t/nghttp2/issues" > Issues< / a > < / li >
2013-12-06 17:29:39 +01:00
< / ul >
< / div >
< / nav >
< section data-toggle = "wy-nav-shift" class = "wy-nav-content-wrap" >
2014-02-02 10:36:57 +01:00
< nav class = "wy-nav-top" role = "navigation" aria-label = "top navigation" >
< i data-toggle = "wy-nav-top" class = "fa fa-bars" > < / i >
2013-12-06 17:29:39 +01:00
< a href = "index.html" > nghttp2< / a >
< / nav >
< div class = "wy-nav-content" >
< div class = "rst-content" >
2014-02-02 10:36:57 +01:00
< div role = "navigation" aria-label = "breadcrumbs navigation" >
< ul class = "wy-breadcrumbs" >
< li > < a href = "index.html" > Docs< / a > » < / li >
2013-12-06 17:29:39 +01:00
2014-02-02 10:36:57 +01:00
< li > nghttp2 - HTTP/2.0 C Library< / li >
< li class = "wy-breadcrumbs-aside" >
< a href = "_sources/package_README.txt" rel = "nofollow" > View page source< / a >
< / li >
< / ul >
< hr / >
< / div >
< div role = "main" >
2013-07-28 14:26:41 +02:00
< div class = "section" id = "nghttp2-http-2-0-c-library" >
< h1 > nghttp2 - HTTP/2.0 C Library< a class = "headerlink" href = "#nghttp2-http-2-0-c-library" title = "Permalink to this headline" > ¶< / a > < / h1 >
< p > This is an experimental implementation of Hypertext Transfer Protocol
version 2.0.< / p >
< div class = "section" id = "development-status" >
< h2 > Development Status< a class = "headerlink" href = "#development-status" title = "Permalink to this headline" > ¶< / a > < / h2 >
2013-12-05 17:27:51 +01:00
< p > We started to implement HTTP-draft-09/2.0
(< a class = "reference external" href = "http://tools.ietf.org/html/draft-ietf-httpbis-http2-09" > http://tools.ietf.org/html/draft-ietf-httpbis-http2-09< / a > ) and the
2013-08-25 15:59:06 +02:00
header compression
2013-12-05 17:27:51 +01:00
(< a class = "reference external" href = "http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05" > http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05< / a > ).< / p >
2013-08-25 15:59:06 +02:00
< p > The nghttp2 code base was forked from spdylay project.< / p >
< table border = "1" class = "docutils" >
< colgroup >
2013-10-28 15:32:57 +01:00
< col width = "60%" / >
< col width = "40%" / >
2013-08-25 15:59:06 +02:00
< / colgroup >
< thead valign = "bottom" >
< tr class = "row-odd" > < th class = "head" > Features< / th >
2013-12-05 17:27:51 +01:00
< th class = "head" > HTTP-draft-09/2.0< / th >
2013-08-25 15:59:06 +02:00
< / tr >
< / thead >
< tbody valign = "top" >
2013-10-28 15:32:57 +01:00
< tr class = "row-even" > < td > :authority< / td >
2013-08-25 15:59:06 +02:00
< td > Done< / td >
< / tr >
2013-12-05 17:27:51 +01:00
< tr class = "row-odd" > < td > HPACK-draft-05< / td >
2013-08-25 15:59:06 +02:00
< td > Done< / td >
< / tr >
2013-10-28 15:32:57 +01:00
< tr class = "row-even" > < td > SETTINGS_HEADER_TABLE_SIZE< / td >
2013-08-25 15:59:06 +02:00
< td > Done< / td >
< / tr >
2013-10-28 15:32:57 +01:00
< tr class = "row-odd" > < td > SETTINGS_ENABLE_PUSH< / td >
2013-11-02 09:01:32 +01:00
< td > Done< / td >
2013-08-25 15:59:06 +02:00
< / tr >
2013-10-28 15:32:57 +01:00
< tr class = "row-even" > < td > FRAME_SIZE_ERROR< / td >
2013-08-25 15:59:06 +02:00
< td > Done< / td >
< / tr >
2013-10-28 16:24:56 +01:00
< tr class = "row-odd" > < td > SETTINGS with ACK< / td >
< td > Done< / td >
< / tr >
< tr class = "row-even" > < td > Header Continuation< / td >
2014-01-26 15:37:13 +01:00
< td > Done< / td >
2013-08-25 15:59:06 +02:00
< / tr >
2013-10-28 16:24:56 +01:00
< tr class = "row-odd" > < td > ALPN< / td >
2014-01-01 17:03:29 +01:00
< td > Done< / td >
2013-08-25 15:59:06 +02:00
< / tr >
< / tbody >
< / table >
< / div >
< div class = "section" id = "public-test-server" >
< h2 > Public Test Server< a class = "headerlink" href = "#public-test-server" title = "Permalink to this headline" > ¶< / a > < / h2 >
< p > The following endpoints are available to try out nghttp2
2013-12-05 17:27:51 +01:00
implementation. These endpoints supports < tt class = "docutils literal" > < span class = "pre" > HTTP-draft-09/2.0< / span > < / tt > and
2013-08-25 15:59:06 +02:00
the earlier draft versions are not supporeted.< / p >
< ul >
2014-02-05 15:22:31 +01:00
< li > < p class = "first" > < a class = "reference external" href = "https://106.186.112.116" > https://106.186.112.116< / a > (TLS + NPN / ALPN)< / p >
2014-01-26 15:37:13 +01:00
< p > ALPN and NPN offer < tt class = "docutils literal" > < span class = "pre" > HTTP-draft-09/2.0< / span > < / tt > , < tt class = "docutils literal" > < span class = "pre" > spdy/3.1< / span > < / tt > , < tt class = "docutils literal" > < span class = "pre" > spdy/3< / span > < / tt > ,
2013-11-14 16:43:30 +01:00
< tt class = "docutils literal" > < span class = "pre" > spdy/2< / span > < / tt > and < tt class = "docutils literal" > < span class = "pre" > http/1.1< / span > < / tt > .< / p >
2013-08-25 15:59:06 +02:00
< p > Note: certificate is self-signed and a browser will show alert< / p >
< / li >
2013-08-30 17:52:54 +02:00
< li > < p class = "first" > < a class = "reference external" href = "http://106.186.112.116" > http://106.186.112.116< / a > (Upgrade + Direct)< / p >
2013-08-25 15:59:06 +02:00
< / li >
2013-07-28 14:26:41 +02:00
< / ul >
< / div >
< div class = "section" id = "requirements" >
< h2 > Requirements< a class = "headerlink" href = "#requirements" title = "Permalink to this headline" > ¶< / a > < / h2 >
< p > The following packages are needed to build the library:< / p >
< ul class = "simple" >
< li > pkg-config > = 0.20< / li >
< li > zlib > = 1.2.3< / li >
< / ul >
< p > To build and run the unit test programs, the following packages are
required:< / p >
< ul class = "simple" >
< li > cunit > = 2.1< / li >
< / ul >
2013-09-02 16:02:05 +02:00
< p > To build the documentation, you need to install:< / p >
< ul class = "simple" >
< li > sphinx (< a class = "reference external" href = "http://sphinx-doc.org/" > http://sphinx-doc.org/< / a > )< / li >
< / ul >
2013-07-28 14:26:41 +02:00
< p > To build and run the application programs (< tt class = "docutils literal" > < span class = "pre" > nghttp< / span > < / tt > , < tt class = "docutils literal" > < span class = "pre" > nghttpd< / span > < / tt > and
< tt class = "docutils literal" > < span class = "pre" > nghttpx< / span > < / tt > ) in < tt class = "docutils literal" > < span class = "pre" > src< / span > < / tt > directory, the following packages are
required:< / p >
< ul class = "simple" >
< li > OpenSSL > = 1.0.1< / li >
< li > libevent-openssl > = 2.0.8< / li >
< / ul >
2014-01-02 05:33:27 +01:00
< p > ALPN support requires unreleased version OpenSSL > = 1.0.2.< / p >
2013-07-28 14:26:41 +02:00
< p > To enable SPDY protocol in the application program < tt class = "docutils literal" > < span class = "pre" > nghttpx< / span > < / tt > , the
following packages are required:< / p >
< ul class = "simple" >
2014-01-04 03:25:17 +01:00
< li > spdylay > = 1.2.3< / li >
2013-07-28 14:26:41 +02:00
< / ul >
< p > To enable < tt class = "docutils literal" > < span class = "pre" > -a< / span > < / tt > option (getting linked assets from the downloaded
2013-10-10 18:10:06 +02:00
resource) in < tt class = "docutils literal" > < span class = "pre" > nghttp< / span > < / tt > , the following packages are needed:< / p >
2013-07-28 14:26:41 +02:00
< ul class = "simple" >
< li > libxml2 > = 2.7.7< / li >
< / ul >
2014-01-10 17:07:30 +01:00
< p > The HPACK tools require the following package:< / p >
2013-10-28 15:32:57 +01:00
< ul class = "simple" >
2014-01-08 17:49:23 +01:00
< li > jansson > = 2.5< / li >
2013-10-28 15:32:57 +01:00
< / ul >
2014-01-10 17:07:30 +01:00
< p > The Python bindings require the following packages:< / p >
< ul class = "simple" >
< li > cython > = 0.19< / li >
< li > python > = 2.7< / li >
< / ul >
2013-07-28 14:26:41 +02:00
< p > If you are using Ubuntu 12.04, you need the following packages
installed:< / p >
< ul class = "simple" >
< li > autoconf< / li >
< li > automake< / li >
< li > autotools-dev< / li >
< li > libtool< / li >
< li > pkg-config< / li >
< li > zlib1g-dev< / li >
< li > libcunit1-dev< / li >
< li > libssl-dev< / li >
< li > libxml2-dev< / li >
< li > libevent-dev< / li >
2013-10-28 15:32:57 +01:00
< li > libjansson-dev< / li >
2013-07-28 14:26:41 +02:00
< / ul >
< p > spdylay is not packaged in Ubuntu, so you need to build it yourself:
2013-11-21 14:06:29 +01:00
< a class = "reference external" href = "http://tatsuhiro-t.github.io/spdylay/" > http://tatsuhiro-t.github.io/spdylay/< / a > < / p >
2013-07-28 14:26:41 +02:00
< / div >
< div class = "section" id = "build-from-git" >
< h2 > Build from git< a class = "headerlink" href = "#build-from-git" title = "Permalink to this headline" > ¶< / a > < / h2 >
< p > Building from git is easy, but please be sure that at least autoconf 2.68 is
used:< / p >
< div class = "highlight-c" > < pre > $ autoreconf -i
$ automake
$ autoconf
$ ./configure
$ make< / pre >
< / div >
< / div >
< div class = "section" id = "building-documentation" >
< h2 > Building documentation< a class = "headerlink" href = "#building-documentation" title = "Permalink to this headline" > ¶< / a > < / h2 >
< div class = "admonition note" >
< p class = "first admonition-title" > Note< / p >
< p class = "last" > Documentation is still incomplete.< / p >
< / div >
< p > To build documentation, run:< / p >
< div class = "highlight-c" > < pre > $ make html< / pre >
< / div >
< p > The documents will be generated under < tt class = "docutils literal" > < span class = "pre" > doc/manual/html/< / span > < / tt > .< / p >
< p > The generated documents will not be installed with < tt class = "docutils literal" > < span class = "pre" > make< / span > < span class = "pre" > install< / span > < / tt > .< / p >
2013-08-03 13:03:39 +02:00
< p > The online documentation is available at
< a class = "reference external" href = "http://tatsuhiro-t.github.io/nghttp2/" > http://tatsuhiro-t.github.io/nghttp2/< / a > < / p >
2013-07-28 14:26:41 +02:00
< / div >
< div class = "section" id = "client-server-and-proxy-programs" >
< h2 > Client, Server and Proxy programs< a class = "headerlink" href = "#client-server-and-proxy-programs" title = "Permalink to this headline" > ¶< / a > < / h2 >
< p > The src directory contains HTTP/2.0 client, server and proxy programs.< / p >
< div class = "section" id = "nghttp-client" >
< h3 > nghttp - client< a class = "headerlink" href = "#nghttp-client" title = "Permalink to this headline" > ¶< / a > < / h3 >
2013-08-04 11:30:37 +02:00
< p > < tt class = "docutils literal" > < span class = "pre" > nghttp< / span > < / tt > is a HTTP/2.0 client. It can connect to the HTTP/2.0 server
2014-01-01 17:03:29 +01:00
with prior knowledge, HTTP Upgrade and NPN/ALPN TLS extension.< / p >
2013-07-28 14:26:41 +02:00
< p > It has verbose output mode for framing information. Here is sample
output from < tt class = "docutils literal" > < span class = "pre" > nghttp< / span > < / tt > client:< / p >
2013-08-25 15:59:06 +02:00
< div class = "highlight-c" > < pre > $ src/nghttp -vn https://localhost:8443
2013-10-28 15:32:57 +01:00
[ 0.003] NPN select next protocol: the remote server offers:
2013-12-05 17:27:51 +01:00
* HTTP-draft-09/2.0
2013-07-28 14:26:41 +02:00
* spdy/3
* spdy/2
* http/1.1
2013-12-05 17:27:51 +01:00
NPN selected the protocol: HTTP-draft-09/2.0
2013-10-28 15:32:57 +01:00
[ 0.005] send SETTINGS frame < length=16, flags=0x00, stream_id=0>
2013-08-25 15:59:06 +02:00
(niv=2)
2013-10-28 15:32:57 +01:00
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
[ 0.006] send HEADERS frame < length=47, flags=0x05, stream_id=1>
2013-07-28 14:26:41 +02:00
; END_STREAM | END_HEADERS
; Open new stream
2013-10-28 15:32:57 +01:00
:authority: localhost:8443
2013-07-28 14:26:41 +02:00
:method: GET
:path: /
:scheme: https
accept: */*
accept-encoding: gzip, deflate
user-agent: nghttp2/0.1.0-DEV
2013-10-28 15:32:57 +01:00
[ 0.006] recv SETTINGS frame < length=16, flags=0x00, stream_id=0>
2013-07-28 14:26:41 +02:00
(niv=2)
2013-10-28 15:32:57 +01:00
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
[ 0.006] send SETTINGS frame < length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[ 0.006] recv WINDOW_UPDATE frame < length=4, flags=0x00, stream_id=0>
2013-08-25 15:59:06 +02:00
(window_size_increment=1000000007)
2013-10-28 15:32:57 +01:00
[ 0.006] recv SETTINGS frame < length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[ 0.006] recv HEADERS frame < length=132, flags=0x04, stream_id=1>
2013-07-28 14:26:41 +02:00
; END_HEADERS
; First response header
2013-10-28 15:32:57 +01:00
:status: 200
2013-07-28 14:26:41 +02:00
accept-ranges: bytes
content-encoding: gzip
2013-10-28 15:32:57 +01:00
content-length: 146
2013-07-28 14:26:41 +02:00
content-type: text/html
2013-10-28 15:32:57 +01:00
date: Sun, 27 Oct 2013 14:23:54 GMT
etag: "b1-4e5535a027780-gzip"
last-modified: Sun, 01 Sep 2013 14:34:22 GMT
server: Apache/2.4.6 (Debian)
2013-07-28 14:26:41 +02:00
vary: Accept-Encoding
via: 1.1 nghttpx
2013-10-28 15:32:57 +01:00
[ 0.006] recv DATA frame < length=146, flags=0x00, stream_id=1>
[ 0.006] recv DATA frame < length=0, flags=0x01, stream_id=1>
2013-08-25 15:59:06 +02:00
; END_STREAM
2013-10-28 15:32:57 +01:00
[ 0.007] send GOAWAY frame < length=8, flags=0x00, stream_id=0>
2013-08-25 15:59:06 +02:00
(last_stream_id=0, error_code=NO_ERROR(0), opaque_data(0)=[])< / pre >
2013-07-28 14:26:41 +02:00
< / div >
2013-08-03 13:03:39 +02:00
< p > The HTTP Upgrade is performed like this:< / p >
2013-08-25 15:59:06 +02:00
< div class = "highlight-c" > < pre > $ src/nghttp -vnu http://localhost:8080
2013-08-03 13:03:39 +02:00
[ 0.000] HTTP Upgrade request
GET / HTTP/1.1
2013-08-25 15:59:06 +02:00
Host: localhost:8080
2013-08-03 13:03:39 +02:00
Connection: Upgrade, HTTP2-Settings
2013-12-05 17:27:51 +01:00
Upgrade: HTTP-draft-09/2.0
2013-08-03 13:03:39 +02:00
HTTP2-Settings: AAAABAAAAGQAAAAHAAD__w
Accept: */*
User-Agent: nghttp2/0.1.0-DEV
2013-08-25 15:59:06 +02:00
[ 0.000] HTTP Upgrade response
2013-08-03 13:03:39 +02:00
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
2013-12-05 17:27:51 +01:00
Upgrade: HTTP-draft-09/2.0
2013-08-03 13:03:39 +02:00
2013-10-28 15:32:57 +01:00
[ 0.001] HTTP Upgrade success
2013-08-25 15:59:06 +02:00
[ 0.001] send SETTINGS frame < length=16, flags=0x00, stream_id=0>
2013-08-03 13:03:39 +02:00
(niv=2)
2013-10-28 15:32:57 +01:00
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
2013-08-25 15:59:06 +02:00
[ 0.001] recv SETTINGS frame < length=16, flags=0x00, stream_id=0>
2013-08-03 13:03:39 +02:00
(niv=2)
2013-10-28 15:32:57 +01:00
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
2013-08-25 15:59:06 +02:00
[ 0.001] recv WINDOW_UPDATE frame < length=4, flags=0x00, stream_id=0>
(window_size_increment=1000000007)
2013-10-28 15:32:57 +01:00
[ 0.001] recv HEADERS frame < length=121, flags=0x04, stream_id=1>
2013-08-03 13:03:39 +02:00
; END_HEADERS
; First response header
2013-10-28 15:32:57 +01:00
:status: 200
2013-08-03 13:03:39 +02:00
accept-ranges: bytes
2013-10-28 15:32:57 +01:00
content-length: 177
2013-08-03 13:03:39 +02:00
content-type: text/html
2013-10-28 15:32:57 +01:00
date: Sun, 27 Oct 2013 14:26:04 GMT
etag: "b1-4e5535a027780"
last-modified: Sun, 01 Sep 2013 14:34:22 GMT
server: Apache/2.4.6 (Debian)
2013-08-03 13:03:39 +02:00
vary: Accept-Encoding
via: 1.1 nghttpx
2013-10-28 15:32:57 +01:00
[ 0.001] recv DATA frame < length=177, flags=0x00, stream_id=1>
2013-08-25 15:59:06 +02:00
[ 0.001] recv DATA frame < length=0, flags=0x01, stream_id=1>
; END_STREAM
2013-10-28 15:32:57 +01:00
[ 0.001] send SETTINGS frame < length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
2013-08-25 15:59:06 +02:00
[ 0.001] send GOAWAY frame < length=8, flags=0x00, stream_id=0>
2013-10-28 15:32:57 +01:00
(last_stream_id=0, error_code=NO_ERROR(0), opaque_data(0)=[])
[ 0.001] recv SETTINGS frame < length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)< / pre >
2013-08-03 13:03:39 +02:00
< / div >
2013-07-28 14:26:41 +02:00
< / div >
< div class = "section" id = "nghttpd-server" >
< h3 > nghttpd - server< a class = "headerlink" href = "#nghttpd-server" title = "Permalink to this headline" > ¶< / a > < / h3 >
< p > < tt class = "docutils literal" > < span class = "pre" > nghttpd< / span > < / tt > is static web server. It is single threaded and
multiplexes connections using non-blocking socket.< / p >
< p > By default, it uses SSL/TLS connection. Use < tt class = "docutils literal" > < span class = "pre" > --no-tls< / span > < / tt > option to
disable it.< / p >
2014-01-01 17:03:29 +01:00
< p > < tt class = "docutils literal" > < span class = "pre" > nghttpd< / span > < / tt > only accept the HTTP/2.0 connection via NPN/ALPN or direct
2013-08-03 13:03:39 +02:00
HTTP/2.0 connection. No HTTP Upgrade is supported.< / p >
2013-12-08 16:07:37 +01:00
< p > < tt class = "docutils literal" > < span class = "pre" > -p< / span > < / tt > option allows users to configure server push.< / p >
2013-07-28 14:26:41 +02:00
< p > Just like < tt class = "docutils literal" > < span class = "pre" > nghttp< / span > < / tt > , it has verbose output mode for framing
information. Here is sample output from < tt class = "docutils literal" > < span class = "pre" > nghttpd< / span > < / tt > server:< / p >
2013-08-25 15:59:06 +02:00
< div class = "highlight-c" > < pre > $ src/nghttpd --no-tls -v 8080
IPv4: listen on port 8080
IPv6: listen on port 8080
2013-10-28 15:32:57 +01:00
[id=1] [ 1.189] send SETTINGS frame < length=8, flags=0x00, stream_id=0>
2013-07-28 14:26:41 +02:00
(niv=1)
2013-10-28 15:32:57 +01:00
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
[id=1] [ 1.191] recv SETTINGS frame < length=16, flags=0x00, stream_id=0>
2013-08-25 15:59:06 +02:00
(niv=2)
2013-10-28 15:32:57 +01:00
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
[id=1] [ 1.191] recv HEADERS frame < length=47, flags=0x05, stream_id=1>
2013-07-28 14:26:41 +02:00
; END_STREAM | END_HEADERS
; Open new stream
2013-10-28 15:32:57 +01:00
:authority: localhost:8080
2013-07-28 14:26:41 +02:00
:method: GET
:path: /
:scheme: http
accept: */*
accept-encoding: gzip, deflate
user-agent: nghttp2/0.1.0-DEV
2013-10-28 15:32:57 +01:00
[id=1] [ 1.192] send SETTINGS frame < length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[id=1] [ 1.192] send HEADERS frame < length=70, flags=0x04, stream_id=1>
2013-07-28 14:26:41 +02:00
; END_HEADERS
; First response header
2013-10-28 15:32:57 +01:00
:status: 404
2013-07-28 14:26:41 +02:00
content-encoding: gzip
content-type: text/html; charset=UTF-8
2013-10-28 15:32:57 +01:00
date: Sun, 27 Oct 2013 14:27:53 GMT
2013-07-28 14:26:41 +02:00
server: nghttpd nghttp2/0.1.0-DEV
2013-10-28 15:32:57 +01:00
[id=1] [ 1.192] send DATA frame < length=117, flags=0x00, stream_id=1>
[id=1] [ 1.192] send DATA frame < length=0, flags=0x01, stream_id=1>
2013-08-25 15:59:06 +02:00
; END_STREAM
2013-10-28 15:32:57 +01:00
[id=1] [ 1.192] stream_id=1 closed
[id=1] [ 1.192] recv SETTINGS frame < length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[id=1] [ 1.192] recv GOAWAY frame < length=8, flags=0x00, stream_id=0>
2013-08-25 15:59:06 +02:00
(last_stream_id=0, error_code=NO_ERROR(0), opaque_data(0)=[])
2013-10-28 15:32:57 +01:00
[id=1] [ 1.192] closed< / pre >
2013-07-28 14:26:41 +02:00
< / div >
< / div >
< div class = "section" id = "nghttpx-proxy" >
< h3 > nghttpx - proxy< a class = "headerlink" href = "#nghttpx-proxy" title = "Permalink to this headline" > ¶< / a > < / h3 >
< p > The < tt class = "docutils literal" > < span class = "pre" > nghttpx< / span > < / tt > is a multi-threaded reverse proxy for
2013-12-05 17:27:51 +01:00
HTTP-draft-09/2.0, SPDY and HTTP/1.1. It has several operation modes:< / p >
2013-07-28 14:26:41 +02:00
< table border = "1" class = "docutils" >
< colgroup >
2013-08-03 13:03:39 +02:00
< col width = "24%" / >
< col width = "40%" / >
< col width = "19%" / >
< col width = "17%" / >
2013-07-28 14:26:41 +02:00
< / colgroup >
< thead valign = "bottom" >
< tr class = "row-odd" > < th class = "head" > Mode option< / th >
< th class = "head" > Frontend< / th >
< th class = "head" > Backend< / th >
< th class = "head" > Note< / th >
< / tr >
< / thead >
< tbody valign = "top" >
2013-08-03 13:03:39 +02:00
< tr class = "row-even" > < td > default mode< / td >
< td > HTTP/2.0, SPDY, HTTP/1.1 (TLS)< / td >
2013-07-28 14:26:41 +02:00
< td > HTTP/1.1< / td >
< td > Reverse proxy< / td >
< / tr >
2013-11-04 10:27:48 +01:00
< tr class = "row-odd" > < td > < tt class = "docutils literal" > < span class = "pre" > --http2-proxy< / span > < / tt > < / td >
2013-08-03 13:03:39 +02:00
< td > HTTP/2.0, SPDY, HTTP/1.1 (TLS)< / td >
2013-07-28 14:26:41 +02:00
< td > HTTP/1.1< / td >
< td > SPDY proxy< / td >
< / tr >
2013-11-04 10:27:48 +01:00
< tr class = "row-even" > < td > < tt class = "docutils literal" > < span class = "pre" > --http2-bridge< / span > < / tt > < / td >
2013-08-03 13:03:39 +02:00
< td > HTTP/2.0, SPDY, HTTP/1.1 (TLS)< / td >
< td > HTTP/2.0 (TLS)< / td >
< td > < / td >
2013-07-28 14:26:41 +02:00
< / tr >
< tr class = "row-odd" > < td > < tt class = "docutils literal" > < span class = "pre" > --client< / span > < / tt > < / td >
2013-08-03 13:03:39 +02:00
< td > HTTP/2.0, HTTP/1.1< / td >
< td > HTTP/2.0 (TLS)< / td >
< td > < / td >
2013-07-28 14:26:41 +02:00
< / tr >
< tr class = "row-even" > < td > < tt class = "docutils literal" > < span class = "pre" > --client-proxy< / span > < / tt > < / td >
2013-08-03 13:03:39 +02:00
< td > HTTP/2.0, HTTP/1.1< / td >
< td > HTTP/2.0 (TLS)< / td >
2013-07-28 14:26:41 +02:00
< td > Forward proxy< / td >
< / tr >
< / tbody >
< / table >
< p > The interesting mode at the moment is the default mode. It works like
2013-12-05 17:27:51 +01:00
a reverse proxy and listens HTTP-draft-09/2.0, SPDY and HTTP/1.1 and
2013-08-03 13:03:39 +02:00
can be deployed SSL/TLS terminator for existing web server.< / p >
2013-11-04 10:27:48 +01:00
< p > The default mode, < tt class = "docutils literal" > < span class = "pre" > --http2-proxy< / span > < / tt > and < tt class = "docutils literal" > < span class = "pre" > --http2-bridge< / span > < / tt > modes use
SSL/TLS in the frontend connection by default. To disable SSL/TLS, use
2013-08-03 13:03:39 +02:00
< tt class = "docutils literal" > < span class = "pre" > --frontend-no-tls< / span > < / tt > option. If that option is used, SPDY is disabled
in the frontend and incoming HTTP/1.1 connection can be upgraded to
HTTP/2.0 through HTTP Upgrade.< / p >
2013-11-04 10:27:48 +01:00
< p > The < tt class = "docutils literal" > < span class = "pre" > --http2-bridge< / span > < / tt > , < tt class = "docutils literal" > < span class = "pre" > --client< / span > < / tt > and < tt class = "docutils literal" > < span class = "pre" > --client-proxy< / span > < / tt > modes use
2013-08-03 13:03:39 +02:00
SSL/TLS in the backend connection by deafult. To disable SSL/TLS, use
< tt class = "docutils literal" > < span class = "pre" > --backend-no-tls< / span > < / tt > option.< / p >
2013-07-28 14:26:41 +02:00
< p > The < tt class = "docutils literal" > < span class = "pre" > nghttpx< / span > < / tt > supports configuration file. See < tt class = "docutils literal" > < span class = "pre" > --conf< / span > < / tt > option and
sample configuration file < tt class = "docutils literal" > < span class = "pre" > nghttpx.conf.sample< / span > < / tt > .< / p >
2013-12-18 16:06:52 +01:00
< p > The < tt class = "docutils literal" > < span class = "pre" > nghttpx< / span > < / tt > does not support server push.< / p >
2013-11-04 10:27:48 +01:00
< p > In the default mode, (without any of < tt class = "docutils literal" > < span class = "pre" > --http2-proxy< / span > < / tt > ,
< tt class = "docutils literal" > < span class = "pre" > --http2-bridge< / span > < / tt > , < tt class = "docutils literal" > < span class = "pre" > --client-proxy< / span > < / tt > and < tt class = "docutils literal" > < span class = "pre" > --client< / span > < / tt > options),
< tt class = "docutils literal" > < span class = "pre" > nghttpx< / span > < / tt > works as reverse proxy to the backend server:< / p >
2013-08-03 13:03:39 +02:00
< div class = "highlight-c" > < div class = "highlight" > < pre > < span class = "n" > Client< / span > < span class = "o" > < --< / span > < span class = "p" > (< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 2.0< / span > < span class = "p" > ,< / span > < span class = "n" > SPDY< / span > < span class = "p" > ,< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 1.1< / span > < span class = "p" > )< / span > < span class = "o" > --> < / span > < span class = "n" > nghttpx< / span > < span class = "o" > < --< / span > < span class = "p" > (< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 1.1< / span > < span class = "p" > )< / span > < span class = "o" > --> < / span > < span class = "n" > Web< / span > < span class = "n" > Server< / span >
< span class = "p" > [< / span > < span class = "n" > reverse< / span > < span class = "n" > proxy< / span > < span class = "p" > ]< / span >
2013-07-28 14:26:41 +02:00
< / pre > < / div >
< / div >
2013-11-04 10:27:48 +01:00
< p > With < tt class = "docutils literal" > < span class = "pre" > --http2-proxy< / span > < / tt > option, it works as so called secure proxy (aka
SPDY proxy):< / p >
2013-08-03 13:03:39 +02:00
< div class = "highlight-c" > < div class = "highlight" > < pre > < span class = "n" > Client< / span > < span class = "o" > < --< / span > < span class = "p" > (< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 2.0< / span > < span class = "p" > ,< / span > < span class = "n" > SPDY< / span > < span class = "p" > ,< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 1.1< / span > < span class = "p" > )< / span > < span class = "o" > --> < / span > < span class = "n" > nghttpx< / span > < span class = "o" > < --< / span > < span class = "p" > (< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 1.1< / span > < span class = "p" > )< / span > < span class = "o" > --> < / span > < span class = "n" > Proxy< / span >
< span class = "p" > [< / span > < span class = "n" > secure< / span > < span class = "n" > proxy< / span > < span class = "p" > ]< / span > < span class = "p" > (< / span > < span class = "n" > e< / span > < span class = "p" > .< / span > < span class = "n" > g< / span > < span class = "p" > .,< / span > < span class = "n" > Squid< / span > < span class = "p" > )< / span >
2013-07-28 14:26:41 +02:00
< / pre > < / div >
< / div >
2013-08-03 13:03:39 +02:00
< p > The < tt class = "docutils literal" > < span class = "pre" > Client< / span > < / tt > in the above is needs to be configured to use
< tt class = "docutils literal" > < span class = "pre" > nghttpx< / span > < / tt > as secure proxy.< / p >
2013-07-28 14:26:41 +02:00
< p > At the time of this writing, Chrome is the only browser which supports
2013-08-03 13:03:39 +02:00
secure proxy. The one way to configure Chrome to use secure proxy is
create proxy.pac script like this:< / p >
2014-01-11 09:13:44 +01:00
< div class = "highlight-javascript" > < div class = "highlight" > < pre > < span class = "kd" > function< / span > < span class = "nx" > FindProxyForURL< / span > < span class = "p" > (< / span > < span class = "nx" > url< / span > < span class = "p" > ,< / span > < span class = "nx" > host< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< span class = "k" > return< / span > < span class = "s2" > " HTTPS SERVERADDR:PORT" < / span > < span class = "p" > ;< / span >
2013-07-28 14:26:41 +02:00
< span class = "p" > }< / span >
< / pre > < / div >
< / div >
< p > < tt class = "docutils literal" > < span class = "pre" > SERVERADDR< / span > < / tt > and < tt class = "docutils literal" > < span class = "pre" > PORT< / span > < / tt > is the hostname/address and port of the
machine nghttpx is running. Please note that Chrome requires valid
2013-08-03 13:03:39 +02:00
certificate for secure proxy.< / p >
2013-07-28 14:26:41 +02:00
< p > Then run chrome with the following arguments:< / p >
< div class = "highlight-c" > < pre > $ google-chrome --proxy-pac-url=file:///path/to/proxy.pac --use-npn< / pre >
< / div >
2013-11-04 10:27:48 +01:00
< p > With < tt class = "docutils literal" > < span class = "pre" > --http2-bridge< / span > < / tt > , it accepts HTTP/2.0, SPDY and HTTP/1.1
2013-07-28 14:26:41 +02:00
connections and communicates with backend in HTTP/2.0:< / p >
2013-08-03 13:03:39 +02:00
< div class = "highlight-c" > < div class = "highlight" > < pre > < span class = "n" > Client< / span > < span class = "o" > < --< / span > < span class = "p" > (< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 2.0< / span > < span class = "p" > ,< / span > < span class = "n" > SPDY< / span > < span class = "p" > ,< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 1.1< / span > < span class = "p" > )< / span > < span class = "o" > --> < / span > < span class = "n" > nghttpx< / span > < span class = "o" > < --< / span > < span class = "p" > (< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 2.0< / span > < span class = "p" > )< / span > < span class = "o" > --> < / span > < span class = "n" > Web< / span > < span class = "n" > or< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 2.0< / span > < span class = "n" > Proxy< / span > < span class = "n" > etc< / span >
< span class = "p" > (< / span > < span class = "n" > e< / span > < span class = "p" > .< / span > < span class = "n" > g< / span > < span class = "p" > .,< / span > < span class = "n" > nghttpx< / span > < span class = "o" > -< / span > < span class = "n" > s< / span > < span class = "p" > )< / span >
2013-07-28 14:26:41 +02:00
< / pre > < / div >
< / div >
2013-08-03 13:03:39 +02:00
< p > With < tt class = "docutils literal" > < span class = "pre" > --client-proxy< / span > < / tt > option, it works as forward proxy and expects
that the backend is HTTP/2.0 proxy:< / p >
< div class = "highlight-c" > < div class = "highlight" > < pre > < span class = "n" > Client< / span > < span class = "o" > < --< / span > < span class = "p" > (< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 2.0< / span > < span class = "p" > ,< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 1.1< / span > < span class = "p" > )< / span > < span class = "o" > --> < / span > < span class = "n" > nghttpx< / span > < span class = "o" > < --< / span > < span class = "p" > (< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 2.0< / span > < span class = "p" > )< / span > < span class = "o" > --> < / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 2.0< / span > < span class = "n" > Proxy< / span >
< span class = "p" > [< / span > < span class = "n" > forward< / span > < span class = "n" > proxy< / span > < span class = "p" > ]< / span > < span class = "p" > (< / span > < span class = "n" > e< / span > < span class = "p" > .< / span > < span class = "n" > g< / span > < span class = "p" > .,< / span > < span class = "n" > nghttpx< / span > < span class = "o" > -< / span > < span class = "n" > s< / span > < span class = "p" > )< / span >
2013-07-28 14:26:41 +02:00
< / pre > < / div >
< / div >
2013-08-03 13:03:39 +02:00
< p > The < tt class = "docutils literal" > < span class = "pre" > Client< / span > < / tt > is needs to be configured to use nghttpx as forward
proxy. The frontend HTTP/1.1 connection can be upgraded to HTTP/2.0
through HTTP Upgrade. With the above configuration, one can use
HTTP/1.1 client to access and test their HTTP/2.0 servers.< / p >
2013-07-28 14:26:41 +02:00
< p > With < tt class = "docutils literal" > < span class = "pre" > --client< / span > < / tt > option, it works as reverse proxy and expects that
the backend is HTTP/2.0 Web server:< / p >
2013-08-03 13:03:39 +02:00
< div class = "highlight-c" > < div class = "highlight" > < pre > < span class = "n" > Client< / span > < span class = "o" > < --< / span > < span class = "p" > (< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 2.0< / span > < span class = "p" > ,< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 1.1< / span > < span class = "p" > )< / span > < span class = "o" > --> < / span > < span class = "n" > nghttpx< / span > < span class = "o" > < --< / span > < span class = "p" > (< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 2.0< / span > < span class = "p" > )< / span > < span class = "o" > --> < / span > < span class = "n" > Web< / span > < span class = "n" > Server< / span >
< span class = "p" > [< / span > < span class = "n" > reverse< / span > < span class = "n" > proxy< / span > < span class = "p" > ]< / span >
2013-07-28 14:26:41 +02:00
< / pre > < / div >
< / div >
2013-08-03 13:03:39 +02:00
< p > The frontend HTTP/1.1 connection can be upgraded to HTTP/2.0
through HTTP Upgrade.< / p >
< p > For the operation modes which talk to the backend in HTTP/2.0 over
SSL/TLS, the backend connections can be tunneled though HTTP
proxy. The proxy is specified using < tt class = "docutils literal" > < span class = "pre" > --backend-http-proxy-uri< / span > < / tt >
option. The following figure illustrates the example of
2013-11-04 10:27:48 +01:00
< tt class = "docutils literal" > < span class = "pre" > --http2-bridge< / span > < / tt > and < tt class = "docutils literal" > < span class = "pre" > --backend-http-proxy-uri< / span > < / tt > option to talk to
2013-08-03 13:03:39 +02:00
the outside HTTP/2.0 proxy through HTTP proxy:< / p >
< div class = "highlight-c" > < div class = "highlight" > < pre > < span class = "n" > Client< / span > < span class = "o" > < --< / span > < span class = "p" > (< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 2.0< / span > < span class = "p" > ,< / span > < span class = "n" > SPDY< / span > < span class = "p" > ,< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 1.1< / span > < span class = "p" > )< / span > < span class = "o" > --> < / span > < span class = "n" > nghttpx< / span > < span class = "o" > < --< / span > < span class = "p" > (< / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 2.0< / span > < span class = "p" > )< / span > < span class = "o" > --< / span >
2013-07-28 14:26:41 +02:00
< span class = "o" > --===================---> < / span > < span class = "n" > HTTP< / span > < span class = "o" > /< / span > < span class = "mf" > 2.0< / span > < span class = "n" > Proxy< / span >
< span class = "p" > (< / span > < span class = "n" > HTTP< / span > < span class = "n" > proxy< / span > < span class = "n" > tunnel< / span > < span class = "p" > )< / span > < span class = "p" > (< / span > < span class = "n" > e< / span > < span class = "p" > .< / span > < span class = "n" > g< / span > < span class = "p" > .,< / span > < span class = "n" > nghttpx< / span > < span class = "o" > -< / span > < span class = "n" > s< / span > < span class = "p" > )< / span >
< / pre > < / div >
< / div >
< / div >
< / div >
2014-01-10 17:07:30 +01:00
< div class = "section" id = "hpack-tools" >
< h2 > HPACK tools< a class = "headerlink" href = "#hpack-tools" title = "Permalink to this headline" > ¶< / a > < / h2 >
< p > The < tt class = "docutils literal" > < span class = "pre" > src< / span > < / tt > directory contains HPACK tools. The < tt class = "docutils literal" > < span class = "pre" > deflatehd< / span > < / tt > is
command-line header compression tool. The < tt class = "docutils literal" > < span class = "pre" > inflatehd< / span > < / tt > is
command-line header decompression tool. Both tools read input from
stdin and write output to stdout. The errors are written to
2014-01-11 09:08:37 +01:00
stderr. They take JSON as input and output. We use the same JSON data
format used in < a class = "reference external" href = "https://github.com/Jxck/hpack-test-case" > https://github.com/Jxck/hpack-test-case< / a > < / p >
2013-10-28 16:24:56 +01:00
< div class = "section" id = "deflatehd-header-compressor" >
< h3 > deflatehd - header compressor< a class = "headerlink" href = "#deflatehd-header-compressor" title = "Permalink to this headline" > ¶< / a > < / h3 >
2014-01-11 09:08:37 +01:00
< p > The < tt class = "docutils literal" > < span class = "pre" > deflatehd< / span > < / tt > reads JSON data or HTTP/1-style header fields from
stdin and outputs compressed header block in JSON.< / p >
< p > For the JSON input, the root JSON object must contain < tt class = "docutils literal" > < span class = "pre" > context< / span > < / tt > key,
which indicates which compression context is used. If it is
< tt class = "docutils literal" > < span class = "pre" > request< / span > < / tt > , request compression context is used. Otherwise, response
compression context is used. The value of < tt class = "docutils literal" > < span class = "pre" > cases< / span > < / tt > key contains the
sequence of input header set. They share the same compression context
and are processed in the order they appear. Each item in the sequence
is a JSON object and it must have at least < tt class = "docutils literal" > < span class = "pre" > headers< / span > < / tt > key. Its value
is an array of a JSON object containing exactly one name/value pair.< / p >
2013-10-28 16:24:56 +01:00
< p > Example:< / p >
2014-01-11 09:13:44 +01:00
< div class = "highlight-json" > < div class = "highlight" > < pre > < span class = "p" > {< / span >
< span class = "nt" > " context" < / span > < span class = "p" > :< / span > < span class = "s2" > " request" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " cases" < / span > < span class = "p" > :< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > [< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " headers" < / span > < span class = "p" > :< / span > < span class = "p" > [< / span >
< span class = "p" > {< / span > < span class = "nt" > " :method" < / span > < span class = "p" > :< / span > < span class = "s2" > " GET" < / span > < span class = "p" > },< / span >
< span class = "p" > {< / span > < span class = "nt" > " :path" < / span > < span class = "p" > :< / span > < span class = "s2" > " /" < / span > < span class = "p" > }< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > ]< / span >
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " headers" < / span > < span class = "p" > :< / span > < span class = "p" > [< / span >
< span class = "p" > {< / span > < span class = "nt" > " :method" < / span > < span class = "p" > :< / span > < span class = "s2" > " POST" < / span > < span class = "p" > },< / span >
< span class = "p" > {< / span > < span class = "nt" > " :path" < / span > < span class = "p" > :< / span > < span class = "s2" > " /" < / span > < span class = "p" > }< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > ]< / span >
< span class = "p" > }< / span >
< span class = "p" > ]< / span >
< span class = "p" > }< / span >
2013-10-28 16:24:56 +01:00
< / pre > < / div >
< / div >
< p > With < tt class = "docutils literal" > < span class = "pre" > -t< / span > < / tt > option, the program can accept more familiar HTTP/1 style
header field block. Each header set is delimited by empty line:< / p >
< p > Example:< / p >
< div class = "highlight-c" > < div class = "highlight" > < pre > < span class = "o" > :< / span > < span class = "n" > method< / span > < span class = "o" > :< / span > < span class = "n" > GET< / span >
< span class = "o" > :< / span > < span class = "n" > scheme< / span > < span class = "o" > :< / span > < span class = "n" > https< / span >
< span class = "o" > :< / span > < span class = "n" > path< / span > < span class = "o" > :< / span > < span class = "o" > /< / span >
< span class = "o" > :< / span > < span class = "n" > method< / span > < span class = "o" > :< / span > < span class = "n" > POST< / span >
< span class = "n" > user< / span > < span class = "o" > -< / span > < span class = "n" > agent< / span > < span class = "o" > :< / span > < span class = "n" > nghttp2< / span >
< / pre > < / div >
< / div >
2014-01-11 09:08:37 +01:00
< p > The output is JSON object. It contains < tt class = "docutils literal" > < span class = "pre" > context< / span > < / tt > key and its value
is < tt class = "docutils literal" > < span class = "pre" > request< / span > < / tt > if the compression context is request, otherwise
< tt class = "docutils literal" > < span class = "pre" > response< / span > < / tt > . The root JSON object also contains < tt class = "docutils literal" > < span class = "pre" > cases< / span > < / tt > key and its
value is an array of JSON object, which has at least following keys:< / p >
2013-10-28 16:24:56 +01:00
< dl class = "docutils" >
< dt > seq< / dt >
< dd > The index of header set in the input.< / dd >
2014-01-11 09:08:37 +01:00
< dt > input_length< / dt >
2013-10-28 16:24:56 +01:00
< dd > The sum of length of name/value pair in the input.< / dd >
2014-01-11 09:08:37 +01:00
< dt > output_length< / dt >
2013-10-28 16:24:56 +01:00
< dd > The length of compressed header block.< / dd >
2014-01-11 09:08:37 +01:00
< dt > percentage_of_original_size< / dt >
< dd > < tt class = "docutils literal" > < span class = "pre" > input_length< / span > < / tt > / < tt class = "docutils literal" > < span class = "pre" > output_length< / span > < / tt > * 100< / dd >
< dt > wire< / dt >
2013-10-28 16:24:56 +01:00
< dd > The compressed header block in hex string.< / dd >
2014-01-11 09:08:37 +01:00
< dt > headers< / dt >
< dd > The input header set.< / dd >
< dt > header_table_size< / dt >
< dd > The header table size adjsuted before deflating header set.< / dd >
2013-10-28 16:24:56 +01:00
< / dl >
< p > Examples:< / p >
2014-01-11 09:13:44 +01:00
< div class = "highlight-json" > < div class = "highlight" > < pre > < span class = "p" > {< / span >
< span class = "nt" > " context" < / span > < span class = "p" > :< / span > < span class = "s2" > " request" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " cases" < / span > < span class = "p" > :< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > [< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " seq" < / span > < span class = "p" > :< / span > < span class = "mi" > 0< / span > < span class = "p" > ,< / span >
< span class = "nt" > " input_length" < / span > < span class = "p" > :< / span > < span class = "mi" > 66< / span > < span class = "p" > ,< / span >
< span class = "nt" > " output_length" < / span > < span class = "p" > :< / span > < span class = "mi" > 20< / span > < span class = "p" > ,< / span >
< span class = "nt" > " percentage_of_original_size" < / span > < span class = "p" > :< / span > < span class = "mf" > 30.303030303030305< / span > < span class = "p" > ,< / span >
< span class = "nt" > " wire" < / span > < span class = "p" > :< / span > < span class = "s2" > " 01881f3468e5891afcbf83868a3d856659c62e3f" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " headers" < / span > < span class = "p" > :< / span > < span class = "p" > [< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :authority" < / span > < span class = "p" > :< / span > < span class = "s2" > " example.org" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :method" < / span > < span class = "p" > :< / span > < span class = "s2" > " GET" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :path" < / span > < span class = "p" > :< / span > < span class = "s2" > " /" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :scheme" < / span > < span class = "p" > :< / span > < span class = "s2" > " https" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " user-agent" < / span > < span class = "p" > :< / span > < span class = "s2" > " nghttp2" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > }< / span >
< span class = "p" > ],< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " header_table_size" < / span > < span class = "p" > :< / span > < span class = "mi" > 4096< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > }< / span >
< span class = "p" > ,< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " seq" < / span > < span class = "p" > :< / span > < span class = "mi" > 1< / span > < span class = "p" > ,< / span >
< span class = "nt" > " input_length" < / span > < span class = "p" > :< / span > < span class = "mi" > 74< / span > < span class = "p" > ,< / span >
< span class = "nt" > " output_length" < / span > < span class = "p" > :< / span > < span class = "mi" > 10< / span > < span class = "p" > ,< / span >
< span class = "nt" > " percentage_of_original_size" < / span > < span class = "p" > :< / span > < span class = "mf" > 13.513513513513514< / span > < span class = "p" > ,< / span >
< span class = "nt" > " wire" < / span > < span class = "p" > :< / span > < span class = "s2" > " 88448504252dd5918485" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " headers" < / span > < span class = "p" > :< / span > < span class = "p" > [< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :authority" < / span > < span class = "p" > :< / span > < span class = "s2" > " example.org" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :method" < / span > < span class = "p" > :< / span > < span class = "s2" > " POST" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :path" < / span > < span class = "p" > :< / span > < span class = "s2" > " /account" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :scheme" < / span > < span class = "p" > :< / span > < span class = "s2" > " https" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " user-agent" < / span > < span class = "p" > :< / span > < span class = "s2" > " nghttp2" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > }< / span >
< span class = "p" > ],< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " header_table_size" < / span > < span class = "p" > :< / span > < span class = "mi" > 4096< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > }< / span >
< span class = "p" > ]< / span >
< span class = "p" > }< / span >
2013-10-28 16:24:56 +01:00
< / pre > < / div >
< / div >
2014-01-11 09:08:37 +01:00
< p > The output can be used as the input for < tt class = "docutils literal" > < span class = "pre" > inflatehd< / span > < / tt > and
< tt class = "docutils literal" > < span class = "pre" > deflatehd< / span > < / tt > .< / p >
< p > With < tt class = "docutils literal" > < span class = "pre" > -d< / span > < / tt > option, the extra < tt class = "docutils literal" > < span class = "pre" > header_table< / span > < / tt > key is added and its
2013-10-28 16:24:56 +01:00
associated value contains the state of dyanmic header table after the
corresponding header set was processed. The value contains following
keys:< / p >
< dl class = "docutils" >
< dt > entries< / dt >
< dd > The entry in the header table. If < tt class = "docutils literal" > < span class = "pre" > referenced< / span > < / tt > is < tt class = "docutils literal" > < span class = "pre" > true< / span > < / tt > , it
is in the reference set. The < tt class = "docutils literal" > < span class = "pre" > size< / span > < / tt > includes the overhead (32
bytes). The < tt class = "docutils literal" > < span class = "pre" > index< / span > < / tt > corresponds to the index of header table.
The < tt class = "docutils literal" > < span class = "pre" > name< / span > < / tt > is the header field name and the < tt class = "docutils literal" > < span class = "pre" > value< / span > < / tt > is the
header field value. They may be displayed as < tt class = "docutils literal" > < span class = "pre" > **DEALLOCATED**< / span > < / tt > ,
which means that the memory for that string is freed and not
2013-12-23 15:51:07 +01:00
available. This will happen when the specifying smaller value in
< tt class = "docutils literal" > < span class = "pre" > -S< / span > < / tt > than < tt class = "docutils literal" > < span class = "pre" > -s< / span > < / tt > .< / dd >
2013-10-28 16:24:56 +01:00
< dt > size< / dt >
< dd > The sum of the spaces entries occupied, this includes the
entry overhead.< / dd >
2014-01-11 09:08:37 +01:00
< dt > max_size< / dt >
2013-10-28 16:24:56 +01:00
< dd > The maximum header table size.< / dd >
2014-01-11 09:08:37 +01:00
< dt > deflate_size< / dt >
< dd > The sum of the spaces entries occupied within
< tt class = "docutils literal" > < span class = "pre" > max_deflate_size< / span > < / tt > .< / dd >
< dt > max_deflate_size< / dt >
2013-10-28 16:24:56 +01:00
< dd > The maximum header table size encoder uses. This can be smaller
2014-01-11 09:08:37 +01:00
than < tt class = "docutils literal" > < span class = "pre" > max_size< / span > < / tt > . In this case, encoder only uses up to first
< tt class = "docutils literal" > < span class = "pre" > max_deflate_size< / span > < / tt > buffer. Since the header table size is still
< tt class = "docutils literal" > < span class = "pre" > max_size< / span > < / tt > , the encoder has to keep track of entries ouside the
< tt class = "docutils literal" > < span class = "pre" > max_deflate_size< / span > < / tt > but inside the < tt class = "docutils literal" > < span class = "pre" > max_size< / span > < / tt > and make sure
that they are no longer referenced.< / dd >
2013-10-28 16:24:56 +01:00
< / dl >
< p > Example:< / p >
2014-01-11 09:13:44 +01:00
< div class = "highlight-json" > < div class = "highlight" > < pre > < span class = "p" > {< / span >
< span class = "nt" > " context" < / span > < span class = "p" > :< / span > < span class = "s2" > " request" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " cases" < / span > < span class = "p" > :< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > [< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " seq" < / span > < span class = "p" > :< / span > < span class = "mi" > 0< / span > < span class = "p" > ,< / span >
< span class = "nt" > " input_length" < / span > < span class = "p" > :< / span > < span class = "mi" > 66< / span > < span class = "p" > ,< / span >
< span class = "nt" > " output_length" < / span > < span class = "p" > :< / span > < span class = "mi" > 20< / span > < span class = "p" > ,< / span >
< span class = "nt" > " percentage_of_original_size" < / span > < span class = "p" > :< / span > < span class = "mf" > 30.303030303030305< / span > < span class = "p" > ,< / span >
< span class = "nt" > " wire" < / span > < span class = "p" > :< / span > < span class = "s2" > " 01881f3468e5891afcbf83868a3d856659c62e3f" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " headers" < / span > < span class = "p" > :< / span > < span class = "p" > [< / span >
2013-10-28 16:24:56 +01:00
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :authority" < / span > < span class = "p" > :< / span > < span class = "s2" > " example.org" < / span >
2013-10-28 16:24:56 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :method" < / span > < span class = "p" > :< / span > < span class = "s2" > " GET" < / span >
2013-10-28 16:24:56 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :path" < / span > < span class = "p" > :< / span > < span class = "s2" > " /" < / span >
2013-10-28 16:24:56 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :scheme" < / span > < span class = "p" > :< / span > < span class = "s2" > " https" < / span >
2013-10-28 16:24:56 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " user-agent" < / span > < span class = "p" > :< / span > < span class = "s2" > " nghttp2" < / span >
2013-10-28 16:24:56 +01:00
< span class = "p" > }< / span >
< span class = "p" > ],< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " header_table_size" < / span > < span class = "p" > :< / span > < span class = "mi" > 4096< / span > < span class = "p" > ,< / span >
< span class = "nt" > " header_table" < / span > < span class = "p" > :< / span > < span class = "p" > {< / span >
< span class = "nt" > " entries" < / span > < span class = "p" > :< / span > < span class = "p" > [< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " index" < / span > < span class = "p" > :< / span > < span class = "mi" > 1< / span > < span class = "p" > ,< / span >
< span class = "nt" > " name" < / span > < span class = "p" > :< / span > < span class = "s2" > " user-agent" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " value" < / span > < span class = "p" > :< / span > < span class = "s2" > " nghttp2" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " referenced" < / span > < span class = "p" > :< / span > < span class = "kc" > true< / span > < span class = "p" > ,< / span >
< span class = "nt" > " size" < / span > < span class = "p" > :< / span > < span class = "mi" > 49< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " index" < / span > < span class = "p" > :< / span > < span class = "mi" > 2< / span > < span class = "p" > ,< / span >
< span class = "nt" > " name" < / span > < span class = "p" > :< / span > < span class = "s2" > " :scheme" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " value" < / span > < span class = "p" > :< / span > < span class = "s2" > " https" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " referenced" < / span > < span class = "p" > :< / span > < span class = "kc" > true< / span > < span class = "p" > ,< / span >
< span class = "nt" > " size" < / span > < span class = "p" > :< / span > < span class = "mi" > 44< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " index" < / span > < span class = "p" > :< / span > < span class = "mi" > 3< / span > < span class = "p" > ,< / span >
< span class = "nt" > " name" < / span > < span class = "p" > :< / span > < span class = "s2" > " :path" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " value" < / span > < span class = "p" > :< / span > < span class = "s2" > " /" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " referenced" < / span > < span class = "p" > :< / span > < span class = "kc" > true< / span > < span class = "p" > ,< / span >
< span class = "nt" > " size" < / span > < span class = "p" > :< / span > < span class = "mi" > 38< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " index" < / span > < span class = "p" > :< / span > < span class = "mi" > 4< / span > < span class = "p" > ,< / span >
< span class = "nt" > " name" < / span > < span class = "p" > :< / span > < span class = "s2" > " :method" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " value" < / span > < span class = "p" > :< / span > < span class = "s2" > " GET" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " referenced" < / span > < span class = "p" > :< / span > < span class = "kc" > true< / span > < span class = "p" > ,< / span >
< span class = "nt" > " size" < / span > < span class = "p" > :< / span > < span class = "mi" > 42< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " index" < / span > < span class = "p" > :< / span > < span class = "mi" > 5< / span > < span class = "p" > ,< / span >
< span class = "nt" > " name" < / span > < span class = "p" > :< / span > < span class = "s2" > " :authority" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " value" < / span > < span class = "p" > :< / span > < span class = "s2" > " example.org" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " referenced" < / span > < span class = "p" > :< / span > < span class = "kc" > true< / span > < span class = "p" > ,< / span >
< span class = "nt" > " size" < / span > < span class = "p" > :< / span > < span class = "mi" > 53< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > }< / span >
< span class = "p" > ],< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " size" < / span > < span class = "p" > :< / span > < span class = "mi" > 226< / span > < span class = "p" > ,< / span >
< span class = "nt" > " max_size" < / span > < span class = "p" > :< / span > < span class = "mi" > 4096< / span > < span class = "p" > ,< / span >
< span class = "nt" > " deflate_size" < / span > < span class = "p" > :< / span > < span class = "mi" > 226< / span > < span class = "p" > ,< / span >
< span class = "nt" > " max_deflate_size" < / span > < span class = "p" > :< / span > < span class = "mi" > 4096< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > }< / span >
2013-10-28 16:24:56 +01:00
< span class = "p" > }< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > ,< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " seq" < / span > < span class = "p" > :< / span > < span class = "mi" > 1< / span > < span class = "p" > ,< / span >
< span class = "nt" > " input_length" < / span > < span class = "p" > :< / span > < span class = "mi" > 74< / span > < span class = "p" > ,< / span >
< span class = "nt" > " output_length" < / span > < span class = "p" > :< / span > < span class = "mi" > 10< / span > < span class = "p" > ,< / span >
< span class = "nt" > " percentage_of_original_size" < / span > < span class = "p" > :< / span > < span class = "mf" > 13.513513513513514< / span > < span class = "p" > ,< / span >
< span class = "nt" > " wire" < / span > < span class = "p" > :< / span > < span class = "s2" > " 88448504252dd5918485" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " headers" < / span > < span class = "p" > :< / span > < span class = "p" > [< / span >
2013-10-28 16:24:56 +01:00
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :authority" < / span > < span class = "p" > :< / span > < span class = "s2" > " example.org" < / span >
2013-10-28 16:24:56 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :method" < / span > < span class = "p" > :< / span > < span class = "s2" > " POST" < / span >
2013-10-28 16:24:56 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :path" < / span > < span class = "p" > :< / span > < span class = "s2" > " /account" < / span >
2013-10-28 16:24:56 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :scheme" < / span > < span class = "p" > :< / span > < span class = "s2" > " https" < / span >
2013-10-28 16:24:56 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " user-agent" < / span > < span class = "p" > :< / span > < span class = "s2" > " nghttp2" < / span >
2013-10-28 16:24:56 +01:00
< span class = "p" > }< / span >
< span class = "p" > ],< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " header_table_size" < / span > < span class = "p" > :< / span > < span class = "mi" > 4096< / span > < span class = "p" > ,< / span >
< span class = "nt" > " header_table" < / span > < span class = "p" > :< / span > < span class = "p" > {< / span >
< span class = "nt" > " entries" < / span > < span class = "p" > :< / span > < span class = "p" > [< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " index" < / span > < span class = "p" > :< / span > < span class = "mi" > 1< / span > < span class = "p" > ,< / span >
< span class = "nt" > " name" < / span > < span class = "p" > :< / span > < span class = "s2" > " :method" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " value" < / span > < span class = "p" > :< / span > < span class = "s2" > " POST" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " referenced" < / span > < span class = "p" > :< / span > < span class = "kc" > true< / span > < span class = "p" > ,< / span >
< span class = "nt" > " size" < / span > < span class = "p" > :< / span > < span class = "mi" > 43< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " index" < / span > < span class = "p" > :< / span > < span class = "mi" > 2< / span > < span class = "p" > ,< / span >
< span class = "nt" > " name" < / span > < span class = "p" > :< / span > < span class = "s2" > " user-agent" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " value" < / span > < span class = "p" > :< / span > < span class = "s2" > " nghttp2" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " referenced" < / span > < span class = "p" > :< / span > < span class = "kc" > true< / span > < span class = "p" > ,< / span >
< span class = "nt" > " size" < / span > < span class = "p" > :< / span > < span class = "mi" > 49< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " index" < / span > < span class = "p" > :< / span > < span class = "mi" > 3< / span > < span class = "p" > ,< / span >
< span class = "nt" > " name" < / span > < span class = "p" > :< / span > < span class = "s2" > " :scheme" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " value" < / span > < span class = "p" > :< / span > < span class = "s2" > " https" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " referenced" < / span > < span class = "p" > :< / span > < span class = "kc" > true< / span > < span class = "p" > ,< / span >
< span class = "nt" > " size" < / span > < span class = "p" > :< / span > < span class = "mi" > 44< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " index" < / span > < span class = "p" > :< / span > < span class = "mi" > 4< / span > < span class = "p" > ,< / span >
< span class = "nt" > " name" < / span > < span class = "p" > :< / span > < span class = "s2" > " :path" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " value" < / span > < span class = "p" > :< / span > < span class = "s2" > " /" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " referenced" < / span > < span class = "p" > :< / span > < span class = "kc" > false< / span > < span class = "p" > ,< / span >
< span class = "nt" > " size" < / span > < span class = "p" > :< / span > < span class = "mi" > 38< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " index" < / span > < span class = "p" > :< / span > < span class = "mi" > 5< / span > < span class = "p" > ,< / span >
< span class = "nt" > " name" < / span > < span class = "p" > :< / span > < span class = "s2" > " :method" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " value" < / span > < span class = "p" > :< / span > < span class = "s2" > " GET" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " referenced" < / span > < span class = "p" > :< / span > < span class = "kc" > false< / span > < span class = "p" > ,< / span >
< span class = "nt" > " size" < / span > < span class = "p" > :< / span > < span class = "mi" > 42< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " index" < / span > < span class = "p" > :< / span > < span class = "mi" > 6< / span > < span class = "p" > ,< / span >
< span class = "nt" > " name" < / span > < span class = "p" > :< / span > < span class = "s2" > " :authority" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " value" < / span > < span class = "p" > :< / span > < span class = "s2" > " example.org" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " referenced" < / span > < span class = "p" > :< / span > < span class = "kc" > true< / span > < span class = "p" > ,< / span >
< span class = "nt" > " size" < / span > < span class = "p" > :< / span > < span class = "mi" > 53< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > }< / span >
< span class = "p" > ],< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " size" < / span > < span class = "p" > :< / span > < span class = "mi" > 269< / span > < span class = "p" > ,< / span >
< span class = "nt" > " max_size" < / span > < span class = "p" > :< / span > < span class = "mi" > 4096< / span > < span class = "p" > ,< / span >
< span class = "nt" > " deflate_size" < / span > < span class = "p" > :< / span > < span class = "mi" > 269< / span > < span class = "p" > ,< / span >
< span class = "nt" > " max_deflate_size" < / span > < span class = "p" > :< / span > < span class = "mi" > 4096< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > }< / span >
2013-10-28 16:24:56 +01:00
< span class = "p" > }< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > ]< / span >
< span class = "p" > }< / span >
2013-10-28 16:24:56 +01:00
< / pre > < / div >
< / div >
< / div >
< div class = "section" id = "inflatehd-header-decompressor" >
< h3 > inflatehd - header decompressor< a class = "headerlink" href = "#inflatehd-header-decompressor" title = "Permalink to this headline" > ¶< / a > < / h3 >
2014-01-11 09:08:37 +01:00
< p > The < tt class = "docutils literal" > < span class = "pre" > inflatehd< / span > < / tt > reads JSON data from stdin and outputs decompressed
name/value pairs in JSON.< / p >
< p > The root JSON object must contain < tt class = "docutils literal" > < span class = "pre" > context< / span > < / tt > key, which indicates
which compression context is used. If it is < tt class = "docutils literal" > < span class = "pre" > request< / span > < / tt > , request
compression context is used. Otherwise, response compression context
is used. The value of < tt class = "docutils literal" > < span class = "pre" > cases< / span > < / tt > key contains the sequence of
compressed header block. They share the same compression context and
are processed in the order they appear. Each item in the sequence is a
JSON object and it must have at least < tt class = "docutils literal" > < span class = "pre" > wire< / span > < / tt > key. Its value is a
string containing compressed header block in hex string.< / p >
2013-10-28 16:24:56 +01:00
< p > Example:< / p >
2014-01-11 09:13:44 +01:00
< div class = "highlight-json" > < div class = "highlight" > < pre > < span class = "p" > {< / span >
< span class = "nt" > " context" < / span > < span class = "p" > :< / span > < span class = "s2" > " request" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " cases" < / span > < span class = "p" > :< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > [< / span >
2014-01-11 09:13:44 +01:00
< span class = "p" > {< / span > < span class = "nt" > " wire" < / span > < span class = "p" > :< / span > < span class = "s2" > " 8285" < / span > < span class = "p" > },< / span >
< span class = "p" > {< / span > < span class = "nt" > " wire" < / span > < span class = "p" > :< / span > < span class = "s2" > " 8583" < / span > < span class = "p" > }< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > ]< / span >
< span class = "p" > }< / span >
2013-10-28 16:24:56 +01:00
< / pre > < / div >
< / div >
2014-01-11 09:08:37 +01:00
< p > The output is JSON object. It contains < tt class = "docutils literal" > < span class = "pre" > context< / span > < / tt > key and its value
is < tt class = "docutils literal" > < span class = "pre" > request< / span > < / tt > if the compression context is request, otherwise
< tt class = "docutils literal" > < span class = "pre" > response< / span > < / tt > . The root JSON object also contains < tt class = "docutils literal" > < span class = "pre" > cases< / span > < / tt > key and its
value is an array of JSON object, which has at least following keys:< / p >
2013-10-28 16:24:56 +01:00
< dl class = "docutils" >
< dt > seq< / dt >
< dd > The index of header set in the input.< / dd >
< dt > headers< / dt >
2014-01-11 09:08:37 +01:00
< dd > The JSON array contains decompressed name/value pairs.< / dd >
< dt > wire< / dt >
< dd > The compressed header block in hex string.< / dd >
< dt > header_table_size< / dt >
< dd > The header table size adjsuted before inflating compressed header
block.< / dd >
2013-10-28 16:24:56 +01:00
< / dl >
< p > Example:< / p >
2014-01-11 09:13:44 +01:00
< div class = "highlight-json" > < div class = "highlight" > < pre > < span class = "p" > {< / span >
< span class = "nt" > " context" < / span > < span class = "p" > :< / span > < span class = "s2" > " request" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " cases" < / span > < span class = "p" > :< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > [< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " seq" < / span > < span class = "p" > :< / span > < span class = "mi" > 0< / span > < span class = "p" > ,< / span >
< span class = "nt" > " wire" < / span > < span class = "p" > :< / span > < span class = "s2" > " 01881f3468e5891afcbf83868a3d856659c62e3f" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " headers" < / span > < span class = "p" > :< / span > < span class = "p" > [< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :authority" < / span > < span class = "p" > :< / span > < span class = "s2" > " example.org" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :method" < / span > < span class = "p" > :< / span > < span class = "s2" > " GET" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :path" < / span > < span class = "p" > :< / span > < span class = "s2" > " /" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :scheme" < / span > < span class = "p" > :< / span > < span class = "s2" > " https" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " user-agent" < / span > < span class = "p" > :< / span > < span class = "s2" > " nghttp2" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > }< / span >
< span class = "p" > ],< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " header_table_size" < / span > < span class = "p" > :< / span > < span class = "mi" > 4096< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > }< / span >
< span class = "p" > ,< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " seq" < / span > < span class = "p" > :< / span > < span class = "mi" > 1< / span > < span class = "p" > ,< / span >
< span class = "nt" > " wire" < / span > < span class = "p" > :< / span > < span class = "s2" > " 88448504252dd5918485" < / span > < span class = "p" > ,< / span >
< span class = "nt" > " headers" < / span > < span class = "p" > :< / span > < span class = "p" > [< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :method" < / span > < span class = "p" > :< / span > < span class = "s2" > " POST" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :path" < / span > < span class = "p" > :< / span > < span class = "s2" > " /account" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " user-agent" < / span > < span class = "p" > :< / span > < span class = "s2" > " nghttp2" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :scheme" < / span > < span class = "p" > :< / span > < span class = "s2" > " https" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > },< / span >
< span class = "p" > {< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " :authority" < / span > < span class = "p" > :< / span > < span class = "s2" > " example.org" < / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > }< / span >
< span class = "p" > ],< / span >
2014-01-11 09:13:44 +01:00
< span class = "nt" > " header_table_size" < / span > < span class = "p" > :< / span > < span class = "mi" > 4096< / span >
2014-01-11 09:08:37 +01:00
< span class = "p" > }< / span >
< span class = "p" > ]< / span >
< span class = "p" > }< / span >
2013-10-28 16:24:56 +01:00
< / pre > < / div >
< / div >
2014-01-11 09:08:37 +01:00
< p > The output can be used as the input for < tt class = "docutils literal" > < span class = "pre" > deflatehd< / span > < / tt > and
< tt class = "docutils literal" > < span class = "pre" > inflatehd< / span > < / tt > .< / p >
< p > With < tt class = "docutils literal" > < span class = "pre" > -d< / span > < / tt > option, the extra < tt class = "docutils literal" > < span class = "pre" > header_table< / span > < / tt > key is added and its
2013-10-28 16:24:56 +01:00
associated value contains the state of dyanmic header table after the
corresponding header set was processed. The format is the same as
< tt class = "docutils literal" > < span class = "pre" > deflatehd< / span > < / tt > .< / p >
< / div >
< / div >
2014-01-10 17:07:30 +01:00
< div class = "section" id = "python-bindings" >
< h2 > Python bindings< a class = "headerlink" href = "#python-bindings" title = "Permalink to this headline" > ¶< / a > < / h2 >
< p > This < tt class = "docutils literal" > < span class = "pre" > python< / span > < / tt > directory contains nghttp2 Python bindings. The
bindings currently only provide HPACK compressor and decompressor
classes.< / p >
< p > The extension module is called < tt class = "docutils literal" > < span class = "pre" > nghttp2< / span > < / tt > .< / p >
< p > < tt class = "docutils literal" > < span class = "pre" > make< / span > < / tt > will build the bindings and target Python version is
determined by configure script. If the detected Python version is not
what you expect, specify a path to Python executable in < tt class = "docutils literal" > < span class = "pre" > PYTHON< / span > < / tt >
variable as an argument to configure script (e.g., < tt class = "docutils literal" > < span class = "pre" > ./configure< / span >
< span class = "pre" > PYTHON=/usr/bin/python3.3< / span > < / tt > ).< / p >
< div class = "section" id = "example" >
< 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
and decompressor in Python:< / p >
2014-01-10 18:03:15 +01:00
< div class = "highlight-python" > < div class = "highlight" > < pre > < span class = "kn" > import< / span > < span class = "nn" > binascii< / span >
< span class = "kn" > import< / span > < span class = "nn" > nghttp2< / span >
2014-01-10 17:07:30 +01:00
2014-01-10 18:03:15 +01:00
< 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 >
< 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 >
2014-01-10 17:07:30 +01:00
2014-01-10 18:03:15 +01:00
< 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" > ' foo' < / span > < span class = "p" > ,< / span > < span class = "n" > b< / span > < span class = "s" > ' bar' < / span > < span class = "p" > ),< / span >
< span class = "p" > (< / span > < span class = "n" > b< / span > < span class = "s" > ' baz' < / span > < span class = "p" > ,< / span > < span class = "n" > b< / span > < span class = "s" > ' buz' < / span > < span class = "p" > )])< / span >
< 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 >
2014-01-10 17:07:30 +01:00
2014-01-10 18:03:15 +01:00
< 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 >
< span class = "k" > print< / span > < span class = "p" > (< / span > < span class = "n" > hdrs< / span > < span class = "p" > )< / span >
< / pre > < / div >
2014-01-10 17:07:30 +01:00
< / div >
< / div >
< / div >
2013-07-28 14:26:41 +02:00
< / div >
2014-02-02 10:36:57 +01:00
< / div >
2013-12-06 17:29:39 +01:00
< footer >
2014-02-02 10:36:57 +01:00
< div class = "rst-footer-buttons" role = "navigation" aria-label = "footer navigation" >
2013-12-06 17:29:39 +01:00
2014-02-05 15:22:31 +01:00
< a href = "tutorial-client.html" class = "btn btn-neutral float-right" title = "Tutorial: HTTP/2.0 client" / > Next < span class = "fa fa-arrow-circle-right" > < / span > < / a >
2013-12-06 17:29:39 +01:00
2014-02-05 15:22:31 +01:00
< a href = "index.html" class = "btn btn-neutral" title = "nghttp2 - HTTP/2.0 C Library" > < span class = "fa fa-arrow-circle-left" > < / span > Previous< / a >
2013-12-06 17:29:39 +01:00
< / div >
< hr / >
2014-02-02 10:36:57 +01:00
< div role = "contentinfo" >
< p >
© Copyright 2012, 2014, Tatsuhiro Tsujikawa.
< / p >
< / div >
2013-07-28 14:26:41 +02:00
2014-02-02 10:36:57 +01:00
< a href = "https://github.com/snide/sphinx_rtd_theme" > Sphinx theme< / a > provided by < a href = "https://readthedocs.org" > Read the Docs< / a >
2013-12-06 17:29:39 +01:00
< / footer >
2013-07-28 14:26:41 +02:00
< / div >
< / div >
2013-12-06 17:29:39 +01:00
< / section >
< / div >
< / body >
2013-07-28 14:26:41 +02:00
< / html >