Update doc
This commit is contained in:
parent
f14ac89732
commit
9698b58022
683
apiref.html
683
apiref.html
File diff suppressed because it is too large
Load Diff
228
genindex.html
228
genindex.html
|
@ -80,7 +80,7 @@
|
|||
|
||||
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="package_README.html">nghttp2 - HTTP/2.0 C Library</a><ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="package_README.html">nghttp2 - HTTP/2 C Library</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#development-status">Development Status</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#public-test-server">Public Test Server</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#requirements">Requirements</a></li>
|
||||
|
@ -92,11 +92,11 @@
|
|||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#python-bindings">Python bindings</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="tutorial-client.html">Tutorial: HTTP/2.0 client</a><ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="tutorial-client.html">Tutorial: HTTP/2 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-l1"><a class="reference internal" href="tutorial-server.html">Tutorial: HTTP/2 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>
|
||||
|
@ -156,6 +156,50 @@
|
|||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%" valign="top"><dl>
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_ALTSVC">NGHTTP2_ALTSVC (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_altsvc">nghttp2_altsvc (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_altsvc.hd">nghttp2_altsvc.hd (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_altsvc.host">nghttp2_altsvc.host (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_altsvc.host_len">nghttp2_altsvc.host_len (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_altsvc.max_age">nghttp2_altsvc.max_age (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_altsvc.origin">nghttp2_altsvc.origin (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_altsvc.origin_len">nghttp2_altsvc.origin_len (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_altsvc.port">nghttp2_altsvc.port (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_altsvc.protocol_id">nghttp2_altsvc.protocol_id (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_altsvc.protocol_id_len">nghttp2_altsvc.protocol_id_len (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_before_frame_send_callback">nghttp2_before_frame_send_callback (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
@ -172,6 +216,14 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_CLEARTEXT_PROTO_VERSION_ID">NGHTTP2_CLEARTEXT_PROTO_VERSION_ID (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_CLEARTEXT_PROTO_VERSION_ID_LEN">NGHTTP2_CLEARTEXT_PROTO_VERSION_ID_LEN (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_CLIENT_CONNECTION_HEADER">NGHTTP2_CLIENT_CONNECTION_HEADER (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
@ -180,6 +232,14 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_CLIENT_CONNECTION_PREFACE">NGHTTP2_CLIENT_CONNECTION_PREFACE (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_CLIENT_CONNECTION_PREFACE_LEN">NGHTTP2_CLIENT_CONNECTION_PREFACE_LEN (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_COMPRESSION_ERROR">NGHTTP2_COMPRESSION_ERROR (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
@ -204,6 +264,18 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_data_flag">nghttp2_data_flag (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_DATA_FLAG_EOF">NGHTTP2_DATA_FLAG_EOF (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_DATA_FLAG_NONE">NGHTTP2_DATA_FLAG_NONE (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_data_provider">nghttp2_data_provider (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
@ -232,6 +304,10 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_DEFAULT_WEIGHT">NGHTTP2_DEFAULT_WEIGHT (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_ENHANCE_YOUR_CALM">NGHTTP2_ENHANCE_YOUR_CALM (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
@ -240,6 +316,10 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_ERR_DATA_EXIST">NGHTTP2_ERR_DATA_EXIST (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_ERR_DEFERRED">NGHTTP2_ERR_DEFERRED (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
@ -396,7 +476,11 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_FLAG_PRIORITY">NGHTTP2_FLAG_PRIORITY (C macro)</a>
|
||||
<dt><a href="apiref.html#c.NGHTTP2_FLAG_PRIORITY_DEPENDENCY">NGHTTP2_FLAG_PRIORITY_DEPENDENCY (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_FLAG_PRIORITY_GROUP">NGHTTP2_FLAG_PRIORITY_GROUP (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
|
@ -408,6 +492,10 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_frame.altsvc">nghttp2_frame.altsvc (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_frame.data">nghttp2_frame.data (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
@ -564,7 +652,7 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_headers.pri">nghttp2_headers.pri (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_headers.pri_spec">nghttp2_headers.pri_spec (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
|
@ -620,18 +708,32 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_MAX_WEIGHT">NGHTTP2_MAX_WEIGHT (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_MAX_WINDOW_SIZE">NGHTTP2_MAX_WINDOW_SIZE (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_MIN_WEIGHT">NGHTTP2_MIN_WEIGHT (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_NO_ERROR">NGHTTP2_NO_ERROR (C macro)</a>
|
||||
</dt>
|
||||
|
||||
</dl></td>
|
||||
<td style="width: 33%" valign="top"><dl>
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_nv">nghttp2_nv (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_nv.flags">nghttp2_nv.flags (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_nv.name">nghttp2_nv.name (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
@ -639,8 +741,6 @@
|
|||
<dt><a href="apiref.html#c.nghttp2_nv.namelen">nghttp2_nv.namelen (C member)</a>
|
||||
</dt>
|
||||
|
||||
</dl></td>
|
||||
<td style="width: 33%" valign="top"><dl>
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_nv.value">nghttp2_nv.value (C member)</a>
|
||||
</dt>
|
||||
|
@ -654,6 +754,18 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_nv_flag">nghttp2_nv_flag (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_NV_FLAG_NO_INDEX">NGHTTP2_NV_FLAG_NO_INDEX (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_NV_FLAG_NONE">NGHTTP2_NV_FLAG_NONE (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_on_begin_headers_callback">nghttp2_on_begin_headers_callback (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
@ -690,35 +802,27 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_opt">nghttp2_opt (C type)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_option">nghttp2_option (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE">NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE (C macro)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_option_del">nghttp2_option_del (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_OPT_NO_AUTO_STREAM_WINDOW_UPDATE">NGHTTP2_OPT_NO_AUTO_STREAM_WINDOW_UPDATE (C macro)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_option_new">nghttp2_option_new (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS">NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS (C macro)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_option_set_no_auto_connection_window_update">nghttp2_option_set_no_auto_connection_window_update (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_opt_set">nghttp2_opt_set (C type)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_option_set_no_auto_stream_window_update">nghttp2_option_set_no_auto_stream_window_update (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_opt_set.no_auto_connection_window_update">nghttp2_opt_set.no_auto_connection_window_update (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_opt_set.no_auto_stream_window_update">nghttp2_opt_set.no_auto_stream_window_update (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_opt_set.peer_max_concurrent_streams">nghttp2_opt_set.peer_max_concurrent_streams (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_option_set_peer_max_concurrent_streams">nghttp2_option_set_peer_max_concurrent_streams (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
|
@ -738,14 +842,6 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_PRI_DEFAULT">NGHTTP2_PRI_DEFAULT (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_PRI_LOWEST">NGHTTP2_PRI_LOWEST (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_PRIORITY">NGHTTP2_PRIORITY (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
@ -758,7 +854,71 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_priority.pri">nghttp2_priority.pri (C member)</a>
|
||||
<dt><a href="apiref.html#c.nghttp2_priority.pri_spec">nghttp2_priority.pri_spec (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_priority_dep">nghttp2_priority_dep (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_priority_dep.exclusive">nghttp2_priority_dep.exclusive (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_priority_dep.stream_id">nghttp2_priority_dep.stream_id (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_priority_group">nghttp2_priority_group (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_priority_group.pri_group_id">nghttp2_priority_group.pri_group_id (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_priority_group.weight">nghttp2_priority_group.weight (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_priority_spec">nghttp2_priority_spec (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_priority_spec.dep">nghttp2_priority_spec.dep (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_priority_spec.group">nghttp2_priority_spec.group (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_priority_spec.pri_type">nghttp2_priority_spec.pri_type (C member)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_priority_spec_dep_init">nghttp2_priority_spec_dep_init (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_priority_spec_group_init">nghttp2_priority_spec_group_init (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_priority_type">nghttp2_priority_type (C type)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_PRIORITY_TYPE_DEP">NGHTTP2_PRIORITY_TYPE_DEP (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_PRIORITY_TYPE_GROUP">NGHTTP2_PRIORITY_TYPE_GROUP (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.NGHTTP2_PRIORITY_TYPE_NONE">NGHTTP2_PRIORITY_TYPE_NONE (C macro)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
|
@ -930,6 +1090,10 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_get_stream_remote_window_size">nghttp2_session_get_stream_remote_window_size (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_session_get_stream_user_data">nghttp2_session_get_stream_user_data (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
@ -1050,6 +1214,10 @@
|
|||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_submit_altsvc">nghttp2_submit_altsvc (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
||||
<dt><a href="apiref.html#c.nghttp2_submit_data">nghttp2_submit_data (C function)</a>
|
||||
</dt>
|
||||
|
||||
|
|
26
index.html
26
index.html
|
@ -7,7 +7,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>nghttp2 - HTTP/2.0 C Library — nghttp2 0.4.0-DEV documentation</title>
|
||||
<title>nghttp2 - HTTP/2 C Library — nghttp2 0.4.0-DEV documentation</title>
|
||||
|
||||
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
|||
|
||||
|
||||
<link rel="top" title="nghttp2 0.4.0-DEV documentation" href="#"/>
|
||||
<link rel="next" title="nghttp2 - HTTP/2.0 C Library" href="package_README.html"/>
|
||||
<link rel="next" title="nghttp2 - HTTP/2 C Library" href="package_README.html"/>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
|
||||
|
||||
|
@ -80,7 +80,7 @@
|
|||
|
||||
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="package_README.html">nghttp2 - HTTP/2.0 C Library</a><ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="package_README.html">nghttp2 - HTTP/2 C Library</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#development-status">Development Status</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#public-test-server">Public Test Server</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#requirements">Requirements</a></li>
|
||||
|
@ -92,11 +92,11 @@
|
|||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#python-bindings">Python bindings</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="tutorial-client.html">Tutorial: HTTP/2.0 client</a><ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="tutorial-client.html">Tutorial: HTTP/2 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-l1"><a class="reference internal" href="tutorial-server.html">Tutorial: HTTP/2 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>
|
||||
|
@ -136,7 +136,7 @@
|
|||
<ul class="wy-breadcrumbs">
|
||||
<li><a href="#">Docs</a> »</li>
|
||||
|
||||
<li>nghttp2 - HTTP/2.0 C Library</li>
|
||||
<li>nghttp2 - HTTP/2 C Library</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
</li>
|
||||
|
@ -145,15 +145,15 @@
|
|||
</div>
|
||||
<div role="main">
|
||||
|
||||
<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>
|
||||
<div class="section" id="nghttp2-http-2-c-library">
|
||||
<h1>nghttp2 - HTTP/2 C Library<a class="headerlink" href="#nghttp2-http-2-c-library" title="Permalink to this headline">¶</a></h1>
|
||||
<p>This is an experimental implementation of Hypertext Transfer Protocol
|
||||
version 2.0.</p>
|
||||
version 2.</p>
|
||||
<p>The project is hosted at <a class="reference external" href="https://github.com/tatsuhiro-t/nghttp2">github.com/tatsuhiro-t/nghttp2</a>.</p>
|
||||
<p>Contents:</p>
|
||||
<div class="toctree-wrapper compound">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="package_README.html">nghttp2 - HTTP/2.0 C Library</a><ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="package_README.html">nghttp2 - HTTP/2 C Library</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#development-status">Development Status</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#public-test-server">Public Test Server</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#requirements">Requirements</a></li>
|
||||
|
@ -165,11 +165,11 @@ version 2.0.</p>
|
|||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#python-bindings">Python bindings</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="tutorial-client.html">Tutorial: HTTP/2.0 client</a><ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="tutorial-client.html">Tutorial: HTTP/2 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-l1"><a class="reference internal" href="tutorial-server.html">Tutorial: HTTP/2 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>
|
||||
|
@ -213,7 +213,7 @@ version 2.0.</p>
|
|||
|
||||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||||
|
||||
<a href="package_README.html" class="btn btn-neutral float-right" title="nghttp2 - HTTP/2.0 C Library"/>Next <span class="fa fa-arrow-circle-right"></span></a>
|
||||
<a href="package_README.html" class="btn btn-neutral float-right" title="nghttp2 - HTTP/2 C Library"/>Next <span class="fa fa-arrow-circle-right"></span></a>
|
||||
|
||||
|
||||
</div>
|
||||
|
|
685
nghttp2.h.html
685
nghttp2.h.html
File diff suppressed because it is too large
Load Diff
|
@ -80,7 +80,7 @@
|
|||
|
||||
|
||||
<ul class="current">
|
||||
<li class="toctree-l1"><a class="reference internal" href="package_README.html">nghttp2 - HTTP/2.0 C Library</a><ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="package_README.html">nghttp2 - HTTP/2 C Library</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#development-status">Development Status</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#public-test-server">Public Test Server</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#requirements">Requirements</a></li>
|
||||
|
@ -92,11 +92,11 @@
|
|||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#python-bindings">Python bindings</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="tutorial-client.html">Tutorial: HTTP/2.0 client</a><ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="tutorial-client.html">Tutorial: HTTP/2 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-l1"><a class="reference internal" href="tutorial-server.html">Tutorial: HTTP/2 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>
|
||||
|
@ -148,7 +148,7 @@
|
|||
<div class="section" id="nghttp2ver-h">
|
||||
<h1>nghttp2ver.h<a class="headerlink" href="#nghttp2ver-h" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="cm">/*</span>
|
||||
<span class="cm"> * nghttp2 - HTTP/2.0 C Library</span>
|
||||
<span class="cm"> * nghttp2 - HTTP/2 C Library</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Copyright (c) 2012, 2013 Tatsuhiro Tsujikawa</span>
|
||||
<span class="cm"> *</span>
|
||||
|
|
BIN
objects.inv
BIN
objects.inv
Binary file not shown.
|
@ -7,7 +7,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>nghttp2 - HTTP/2.0 C Library — nghttp2 0.4.0-DEV documentation</title>
|
||||
<title>nghttp2 - HTTP/2 C Library — nghttp2 0.4.0-DEV documentation</title>
|
||||
|
||||
|
||||
|
||||
|
@ -53,8 +53,8 @@
|
|||
|
||||
|
||||
<link rel="top" title="nghttp2 0.4.0-DEV documentation" href="index.html"/>
|
||||
<link rel="next" title="Tutorial: HTTP/2.0 client" href="tutorial-client.html"/>
|
||||
<link rel="prev" title="nghttp2 - HTTP/2.0 C Library" href="index.html"/>
|
||||
<link rel="next" title="Tutorial: HTTP/2 client" href="tutorial-client.html"/>
|
||||
<link rel="prev" title="nghttp2 - HTTP/2 C Library" href="index.html"/>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
|||
|
||||
|
||||
<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-l1 current"><a class="current reference internal" href="">nghttp2 - HTTP/2 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>
|
||||
|
@ -93,11 +93,11 @@
|
|||
<li class="toctree-l2"><a class="reference internal" href="#python-bindings">Python bindings</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="tutorial-client.html">Tutorial: HTTP/2.0 client</a><ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="tutorial-client.html">Tutorial: HTTP/2 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-l1"><a class="reference internal" href="tutorial-server.html">Tutorial: HTTP/2 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>
|
||||
|
@ -137,7 +137,7 @@
|
|||
<ul class="wy-breadcrumbs">
|
||||
<li><a href="index.html">Docs</a> »</li>
|
||||
|
||||
<li>nghttp2 - HTTP/2.0 C Library</li>
|
||||
<li>nghttp2 - HTTP/2 C Library</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
</li>
|
||||
|
@ -146,16 +146,16 @@
|
|||
</div>
|
||||
<div role="main">
|
||||
|
||||
<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>
|
||||
<div class="section" id="nghttp2-http-2-c-library">
|
||||
<h1>nghttp2 - HTTP/2 C Library<a class="headerlink" href="#nghttp2-http-2-c-library" title="Permalink to this headline">¶</a></h1>
|
||||
<p>This is an experimental implementation of Hypertext Transfer Protocol
|
||||
version 2.0.</p>
|
||||
version 2.</p>
|
||||
<div class="section" id="development-status">
|
||||
<h2>Development Status<a class="headerlink" href="#development-status" title="Permalink to this headline">¶</a></h2>
|
||||
<p>We started to implement h2-10
|
||||
(<a class="reference external" href="http://tools.ietf.org/html/draft-ietf-httpbis-http2-10">http://tools.ietf.org/html/draft-ietf-httpbis-http2-10</a>) and the
|
||||
<p>We started to implement h2-11
|
||||
(<a class="reference external" href="http://tools.ietf.org/html/draft-ietf-httpbis-http2-11">http://tools.ietf.org/html/draft-ietf-httpbis-http2-11</a>) and the
|
||||
header compression
|
||||
(<a class="reference external" href="http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-06">http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-06</a>).</p>
|
||||
(<a class="reference external" href="http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07">http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07</a>).</p>
|
||||
<p>The nghttp2 code base was forked from spdylay project.</p>
|
||||
<table border="1" class="docutils">
|
||||
<colgroup>
|
||||
|
@ -164,25 +164,19 @@ header compression
|
|||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr class="row-odd"><th class="head">Features</th>
|
||||
<th class="head">h2-10</th>
|
||||
<th class="head">h2-11</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr class="row-even"><td>HPACK-draft-06</td>
|
||||
<tr class="row-even"><td>HPACK-draft-07</td>
|
||||
<td>Done</td>
|
||||
</tr>
|
||||
<tr class="row-odd"><td>Strict SETTINGS validation</td>
|
||||
<tr class="row-odd"><td>Dependency based priority</td>
|
||||
<td>Done</td>
|
||||
</tr>
|
||||
<tr class="row-even"><td>Disallow client to push</td>
|
||||
<tr class="row-even"><td>ALTSVC frame</td>
|
||||
<td>Done</td>
|
||||
</tr>
|
||||
<tr class="row-odd"><td>Padding</td>
|
||||
<td>Done</td>
|
||||
</tr>
|
||||
<tr class="row-even"><td>END_SEGMENT</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -302,21 +296,21 @@ $ make
|
|||
</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>
|
||||
<p>The src directory contains HTTP/2 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>
|
||||
<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
|
||||
<p><tt class="docutils literal"><span class="pre">nghttp</span></tt> is a HTTP/2 client. It can connect to the HTTP/2 server
|
||||
with prior knowledge, HTTP Upgrade and NPN/ALPN TLS extension.</p>
|
||||
<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>
|
||||
<div class="highlight-c"><div class="highlight"><pre>$ src/nghttp -nv https://localhost:8443
|
||||
[ 0.004][NPN] server offers:
|
||||
* h2-10
|
||||
* h2-11
|
||||
* spdy/3.1
|
||||
* spdy/3
|
||||
* spdy/2
|
||||
* http/1.1
|
||||
The negotiated protocol: h2-10
|
||||
The negotiated protocol: h2-11
|
||||
[ 0.006] send SETTINGS frame <length=10, flags=0x00, stream_id=0>
|
||||
(niv=2)
|
||||
[SETTINGS_MAX_CONCURRENT_STREAMS(3):100]
|
||||
|
@ -371,7 +365,7 @@ The negotiated protocol: h2-10
|
|||
GET / HTTP/1.1
|
||||
Host: localhost:8080
|
||||
Connection: Upgrade, HTTP2-Settings
|
||||
Upgrade: h2-10
|
||||
Upgrade: h2c-11
|
||||
HTTP2-Settings: AwAAAGQEAAD__w
|
||||
Accept: */*
|
||||
User-Agent: nghttp2/0.4.0-DEV
|
||||
|
@ -380,7 +374,7 @@ User-Agent: nghttp2/0.4.0-DEV
|
|||
[ 0.001] HTTP Upgrade response
|
||||
HTTP/1.1 101 Switching Protocols
|
||||
Connection: Upgrade
|
||||
Upgrade: h2-10
|
||||
Upgrade: h2c-11
|
||||
|
||||
|
||||
[ 0.001] HTTP Upgrade success
|
||||
|
@ -426,8 +420,8 @@ Upgrade: h2-10
|
|||
<p><tt class="docutils literal"><span class="pre">nghttpd</span></tt> is a multi-threaded static web server.</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>
|
||||
<p><tt class="docutils literal"><span class="pre">nghttpd</span></tt> only accepts the HTTP/2.0 connection via NPN/ALPN or direct
|
||||
HTTP/2.0 connection. No HTTP Upgrade is supported.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">nghttpd</span></tt> only accepts the HTTP/2 connection via NPN/ALPN or direct
|
||||
HTTP/2 connection. No HTTP Upgrade is supported.</p>
|
||||
<p><tt class="docutils literal"><span class="pre">-p</span></tt> option allows users to configure server push.</p>
|
||||
<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>
|
||||
|
@ -481,13 +475,13 @@ IPv6: listen on port 8080
|
|||
<div class="section" id="nghttpx-proxy">
|
||||
<h3>nghttpx - proxy<a class="headerlink" href="#nghttpx-proxy" title="Permalink to this headline">¶</a></h3>
|
||||
<p><tt class="docutils literal"><span class="pre">nghttpx</span></tt> is a multi-threaded reverse proxy for
|
||||
h2-10, SPDY and HTTP/1.1. It has several operation modes:</p>
|
||||
<tt class="docutils literal"><span class="pre">h2-11</span></tt>, SPDY and HTTP/1.1. It has several operation modes:</p>
|
||||
<table border="1" class="docutils">
|
||||
<colgroup>
|
||||
<col width="24%" />
|
||||
<col width="40%" />
|
||||
<col width="25%" />
|
||||
<col width="38%" />
|
||||
<col width="19%" />
|
||||
<col width="17%" />
|
||||
<col width="18%" />
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr class="row-odd"><th class="head">Mode option</th>
|
||||
|
@ -498,40 +492,40 @@ h2-10, SPDY and HTTP/1.1. It has several operation modes:</p>
|
|||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr class="row-even"><td>default mode</td>
|
||||
<td>HTTP/2.0, SPDY, HTTP/1.1 (TLS)</td>
|
||||
<td>HTTP/2, SPDY, HTTP/1.1 (TLS)</td>
|
||||
<td>HTTP/1.1</td>
|
||||
<td>Reverse proxy</td>
|
||||
</tr>
|
||||
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">--http2-proxy</span></tt></td>
|
||||
<td>HTTP/2.0, SPDY, HTTP/1.1 (TLS)</td>
|
||||
<td>HTTP/2, SPDY, HTTP/1.1 (TLS)</td>
|
||||
<td>HTTP/1.1</td>
|
||||
<td>SPDY proxy</td>
|
||||
</tr>
|
||||
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">--http2-bridge</span></tt></td>
|
||||
<td>HTTP/2.0, SPDY, HTTP/1.1 (TLS)</td>
|
||||
<td>HTTP/2.0 (TLS)</td>
|
||||
<td>HTTP/2, SPDY, HTTP/1.1 (TLS)</td>
|
||||
<td>HTTP/2 (TLS)</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">--client</span></tt></td>
|
||||
<td>HTTP/2.0, HTTP/1.1</td>
|
||||
<td>HTTP/2.0 (TLS)</td>
|
||||
<td>HTTP/2, HTTP/1.1</td>
|
||||
<td>HTTP/2 (TLS)</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">--client-proxy</span></tt></td>
|
||||
<td>HTTP/2.0, HTTP/1.1</td>
|
||||
<td>HTTP/2.0 (TLS)</td>
|
||||
<td>HTTP/2, HTTP/1.1</td>
|
||||
<td>HTTP/2 (TLS)</td>
|
||||
<td>Forward proxy</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>The interesting mode at the moment is the default mode. It works like
|
||||
a reverse proxy and listens for h2-10, SPDY and HTTP/1.1 and
|
||||
can be deployed SSL/TLS terminator for existing web server.</p>
|
||||
a reverse proxy and listens for <tt class="docutils literal"><span class="pre">h2-11</span></tt>, SPDY and HTTP/1.1 and can
|
||||
be deployed SSL/TLS terminator for existing web server.</p>
|
||||
<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
|
||||
<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>
|
||||
HTTP/2 through HTTP Upgrade.</p>
|
||||
<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
|
||||
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>
|
||||
|
@ -541,13 +535,13 @@ sample configuration file <tt class="docutils literal"><span class="pre">nghttpx
|
|||
<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>
|
||||
<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>
|
||||
<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="mi">2</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>
|
||||
</pre></div>
|
||||
</div>
|
||||
<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>
|
||||
<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>
|
||||
<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="mi">2</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>
|
||||
</pre></div>
|
||||
</div>
|
||||
|
@ -568,39 +562,39 @@ certificate for secure proxy.</p>
|
|||
<div class="highlight-c"><div class="highlight"><pre>$ google-chrome --proxy-pac-url=file:///path/to/proxy.pac --use-npn
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>With <tt class="docutils literal"><span class="pre">--http2-bridge</span></tt>, it accepts HTTP/2.0, SPDY and HTTP/1.1
|
||||
connections and communicates with backend in HTTP/2.0:</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> <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>
|
||||
<p>With <tt class="docutils literal"><span class="pre">--http2-bridge</span></tt>, it accepts HTTP/2, SPDY and HTTP/1.1
|
||||
connections and communicates with backend in HTTP/2:</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="mi">2</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="mi">2</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="mi">2</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>
|
||||
</pre></div>
|
||||
</div>
|
||||
<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>
|
||||
that the backend is HTTP/2 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="mi">2</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="mi">2</span><span class="p">)</span> <span class="o">--></span> <span class="n">HTTP</span><span class="o">/</span><span class="mi">2</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>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>The <tt class="docutils literal"><span class="pre">Client</span></tt> needs to be configured to use nghttpx as forward
|
||||
proxy. The frontend HTTP/1.1 connection can be upgraded to HTTP/2.0
|
||||
proxy. The frontend HTTP/1.1 connection can be upgraded to HTTP/2
|
||||
through HTTP Upgrade. With the above configuration, one can use
|
||||
HTTP/1.1 client to access and test their HTTP/2.0 servers.</p>
|
||||
HTTP/1.1 client to access and test their HTTP/2 servers.</p>
|
||||
<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>
|
||||
<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>
|
||||
the backend is HTTP/2 Web server:</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="mi">2</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="mi">2</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>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>The frontend HTTP/1.1 connection can be upgraded to HTTP/2.0
|
||||
<p>The frontend HTTP/1.1 connection can be upgraded to HTTP/2
|
||||
through HTTP Upgrade.</p>
|
||||
<p>For the operation modes which talk to the backend in HTTP/2.0 over
|
||||
<p>For the operation modes which talk to the backend in HTTP/2 over
|
||||
SSL/TLS, the backend connections can be tunneled through 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
|
||||
<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> options to talk to
|
||||
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>
|
||||
the outside HTTP/2 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="mi">2</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="mi">2</span><span class="p">)</span> <span class="o">--</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="o">--===================---></span> <span class="n">HTTP</span><span class="o">/</span><span class="mi">2</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>
|
||||
|
@ -1150,10 +1144,10 @@ BaseRequestHandler usage:</p>
|
|||
|
||||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||||
|
||||
<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>
|
||||
<a href="tutorial-client.html" class="btn btn-neutral float-right" title="Tutorial: HTTP/2 client"/>Next <span class="fa fa-arrow-circle-right"></span></a>
|
||||
|
||||
|
||||
<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>
|
||||
<a href="index.html" class="btn btn-neutral" title="nghttp2 - HTTP/2 C Library"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
|
||||
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="package_README.html">nghttp2 - HTTP/2.0 C Library</a><ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="package_README.html">nghttp2 - HTTP/2 C Library</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#development-status">Development Status</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#public-test-server">Public Test Server</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#requirements">Requirements</a></li>
|
||||
|
@ -99,11 +99,11 @@
|
|||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#python-bindings">Python bindings</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="tutorial-client.html">Tutorial: HTTP/2.0 client</a><ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="tutorial-client.html">Tutorial: HTTP/2 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-l1"><a class="reference internal" href="tutorial-server.html">Tutorial: HTTP/2 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>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -7,7 +7,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Tutorial: HTTP/2.0 client — nghttp2 0.4.0-DEV documentation</title>
|
||||
<title>Tutorial: HTTP/2 client — nghttp2 0.4.0-DEV documentation</title>
|
||||
|
||||
|
||||
|
||||
|
@ -53,8 +53,8 @@
|
|||
|
||||
|
||||
<link rel="top" title="nghttp2 0.4.0-DEV documentation" href="index.html"/>
|
||||
<link rel="next" title="Tutorial: HTTP/2.0 server" href="tutorial-server.html"/>
|
||||
<link rel="prev" title="nghttp2 - HTTP/2.0 C Library" href="package_README.html"/>
|
||||
<link rel="next" title="Tutorial: HTTP/2 server" href="tutorial-server.html"/>
|
||||
<link rel="prev" title="nghttp2 - HTTP/2 C Library" href="package_README.html"/>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
|||
|
||||
|
||||
<ul class="current">
|
||||
<li class="toctree-l1"><a class="reference internal" href="package_README.html">nghttp2 - HTTP/2.0 C Library</a><ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="package_README.html">nghttp2 - HTTP/2 C Library</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#development-status">Development Status</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#public-test-server">Public Test Server</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#requirements">Requirements</a></li>
|
||||
|
@ -93,11 +93,11 @@
|
|||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#python-bindings">Python bindings</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="">Tutorial: HTTP/2.0 client</a><ul>
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="">Tutorial: HTTP/2 client</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#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-l1"><a class="reference internal" href="tutorial-server.html">Tutorial: HTTP/2 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>
|
||||
|
@ -137,7 +137,7 @@
|
|||
<ul class="wy-breadcrumbs">
|
||||
<li><a href="index.html">Docs</a> »</li>
|
||||
|
||||
<li>Tutorial: HTTP/2.0 client</li>
|
||||
<li>Tutorial: HTTP/2 client</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
</li>
|
||||
|
@ -146,9 +146,9 @@
|
|||
</div>
|
||||
<div role="main">
|
||||
|
||||
<div class="section" id="tutorial-http-2-0-client">
|
||||
<h1>Tutorial: HTTP/2.0 client<a class="headerlink" href="#tutorial-http-2-0-client" title="Permalink to this headline">¶</a></h1>
|
||||
<p>In this tutorial, we are going to write very primitive HTTP/2.0
|
||||
<div class="section" id="tutorial-http-2-client">
|
||||
<h1>Tutorial: HTTP/2 client<a class="headerlink" href="#tutorial-http-2-client" title="Permalink to this headline">¶</a></h1>
|
||||
<p>In this tutorial, we are going to write very primitive HTTP/2
|
||||
client. The complete source code, <a class="reference internal" href="#libevent-client-c">libevent-client.c</a>, is attached at
|
||||
the end of this page. It also resides in examples directory in the
|
||||
archive or repository.</p>
|
||||
|
@ -164,7 +164,7 @@ function <tt class="docutils literal"><span class="pre">main()</span></tt> and <
|
|||
library use. The one thing you should look at is setup NPN callback.
|
||||
The NPN callback is used for the client to select the next application
|
||||
protocol over the SSL/TLS transport. In this tutorial, we use
|
||||
<a class="reference internal" href="apiref.html#c.nghttp2_select_next_protocol" title="nghttp2_select_next_protocol"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_select_next_protocol()</span></tt></a> function to select the HTTP/2.0
|
||||
<a class="reference internal" href="apiref.html#c.nghttp2_select_next_protocol" title="nghttp2_select_next_protocol"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_select_next_protocol()</span></tt></a> function to select the HTTP/2
|
||||
protocol the library supports:</p>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="k">static</span> <span class="kt">int</span> <span class="nf">select_next_proto_cb</span><span class="p">(</span><span class="n">SSL</span><span class="o">*</span> <span class="n">ssl</span><span class="p">,</span>
|
||||
<span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">**</span><span class="n">out</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span><span class="n">outlen</span><span class="p">,</span>
|
||||
|
@ -197,7 +197,7 @@ protocol the library supports:</p>
|
|||
</pre></div>
|
||||
</div>
|
||||
<p>We use <tt class="docutils literal"><span class="pre">http2_session_data</span></tt> structure to store the data related to
|
||||
the HTTP/2.0 session:</p>
|
||||
the HTTP/2 session:</p>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span>
|
||||
<span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">;</span>
|
||||
<span class="k">struct</span> <span class="n">evdns_base</span> <span class="o">*</span><span class="n">dnsbase</span><span class="p">;</span>
|
||||
|
@ -317,10 +317,10 @@ nghttp2 session. We’ll explain these callbacks later.</p>
|
|||
<p>The <tt class="xref c c-func docutils literal"><span class="pre">delete_http2_session_data()</span></tt> destroys <tt class="docutils literal"><span class="pre">session_data</span></tt> and frees
|
||||
its bufferevent, so it closes underlying connection as well. It also
|
||||
calls <a class="reference internal" href="apiref.html#c.nghttp2_session_del" title="nghttp2_session_del"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_del()</span></tt></a> to delete nghttp2 session object.</p>
|
||||
<p>We begin HTTP/2.0 communication by sending client connection header,
|
||||
<p>We begin HTTP/2 communication by sending client connection preface,
|
||||
which is 24 bytes magic byte sequence
|
||||
(<a class="reference internal" href="apiref.html#c.NGHTTP2_CLIENT_CONNECTION_HEADER" title="NGHTTP2_CLIENT_CONNECTION_HEADER"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_CLIENT_CONNECTION_HEADER</span></tt></a>) followed by SETTINGS
|
||||
frame. The transmission of client connection header is done in
|
||||
(<a class="reference internal" href="apiref.html#c.NGHTTP2_CLIENT_CONNECTION_PREFACE" title="NGHTTP2_CLIENT_CONNECTION_PREFACE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_CLIENT_CONNECTION_PREFACE</span></tt></a>) and SETTINGS frame. The
|
||||
transmission of client connection header is done in
|
||||
<tt class="docutils literal"><span class="pre">send_client_connection_header()</span></tt>:</p>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="k">static</span> <span class="kt">void</span> <span class="nf">send_client_connection_header</span><span class="p">(</span><span class="n">http2_session_data</span> <span class="o">*</span><span class="n">session_data</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
|
@ -330,8 +330,8 @@ frame. The transmission of client connection header is done in
|
|||
<span class="kt">int</span> <span class="n">rv</span><span class="p">;</span>
|
||||
|
||||
<span class="n">bufferevent_write</span><span class="p">(</span><span class="n">session_data</span><span class="o">-></span><span class="n">bev</span><span class="p">,</span>
|
||||
<span class="n">NGHTTP2_CLIENT_CONNECTION_HEADER</span><span class="p">,</span>
|
||||
<span class="n">NGHTTP2_CLIENT_CONNECTION_HEADER_LEN</span><span class="p">);</span>
|
||||
<span class="n">NGHTTP2_CLIENT_CONNECTION_PREFACE</span><span class="p">,</span>
|
||||
<span class="n">NGHTTP2_CLIENT_CONNECTION_PREFACE_LEN</span><span class="p">);</span>
|
||||
<span class="n">rv</span> <span class="o">=</span> <span class="n">nghttp2_submit_settings</span><span class="p">(</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="n">NGHTTP2_FLAG_NONE</span><span class="p">,</span>
|
||||
<span class="n">iv</span><span class="p">,</span> <span class="n">ARRLEN</span><span class="p">(</span><span class="n">iv</span><span class="p">));</span>
|
||||
<span class="k">if</span><span class="p">(</span><span class="n">rv</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
||||
|
@ -365,7 +365,7 @@ request in <tt class="docutils literal"><span class="pre">submit_request()</span
|
|||
<span class="p">};</span>
|
||||
<span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">"Request headers:</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>
|
||||
<span class="n">print_headers</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="n">hdrs</span><span class="p">,</span> <span class="n">ARRLEN</span><span class="p">(</span><span class="n">hdrs</span><span class="p">));</span>
|
||||
<span class="n">rv</span> <span class="o">=</span> <span class="n">nghttp2_submit_request</span><span class="p">(</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="n">NGHTTP2_PRI_DEFAULT</span><span class="p">,</span>
|
||||
<span class="n">rv</span> <span class="o">=</span> <span class="n">nghttp2_submit_request</span><span class="p">(</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span>
|
||||
<span class="n">hdrs</span><span class="p">,</span> <span class="n">ARRLEN</span><span class="p">(</span><span class="n">hdrs</span><span class="p">),</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">stream_data</span><span class="p">);</span>
|
||||
<span class="k">if</span><span class="p">(</span><span class="n">rv</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="n">errx</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="s">"Could not submit HTTP request: %s"</span><span class="p">,</span> <span class="n">nghttp2_strerror</span><span class="p">(</span><span class="n">rv</span><span class="p">));</span>
|
||||
|
@ -507,7 +507,7 @@ request based on priority and stream ID must be monotonically
|
|||
increased, the stream ID is not assigned just before transmission.
|
||||
The one of the purpose of this callback is get the stream ID assigned
|
||||
to the frame. First we check that the frame is HEADERS frame. Since
|
||||
HEADERS has several meanings in HTTP/2.0, we check that it is request
|
||||
HEADERS has several meanings in HTTP/2, we check that it is request
|
||||
HEADERS (which means that the first HEADERS frame to create a stream).
|
||||
The assigned stream ID is <tt class="docutils literal"><span class="pre">frame->hd.stream_id</span></tt>. Recall that we
|
||||
passed <tt class="docutils literal"><span class="pre">stream_data</span></tt> in the <em>stream_user_data</em> parameter of
|
||||
|
@ -527,6 +527,7 @@ how to use it here.</p>
|
|||
<span class="k">const</span> <span class="n">nghttp2_frame</span> <span class="o">*</span><span class="n">frame</span><span class="p">,</span>
|
||||
<span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span><span class="n">name</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">namelen</span><span class="p">,</span>
|
||||
<span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span><span class="n">value</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">valuelen</span><span class="p">,</span>
|
||||
<span class="kt">uint8_t</span> <span class="n">flags</span><span class="p">,</span>
|
||||
<span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
<span class="n">http2_session_data</span> <span class="o">*</span><span class="n">session_data</span> <span class="o">=</span> <span class="p">(</span><span class="n">http2_session_data</span><span class="o">*</span><span class="p">)</span><span class="n">user_data</span><span class="p">;</span>
|
||||
|
@ -611,13 +612,13 @@ is about to close:</p>
|
|||
stream is going to be closed. Since we have finished to get the
|
||||
resource we want (or the stream was reset by RST_STREAM from the
|
||||
remote peer), we call <a class="reference internal" href="apiref.html#c.nghttp2_session_terminate_session" title="nghttp2_session_terminate_session"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_session_terminate_session()</span></tt></a> to
|
||||
commencing the closure of the HTTP/2.0 session gracefully. If you have
|
||||
commencing the closure of the HTTP/2 session gracefully. If you have
|
||||
some data associated for the stream to be closed, you may delete it
|
||||
here.</p>
|
||||
<div class="section" id="libevent-client-c">
|
||||
<h2>libevent-client.c<a class="headerlink" href="#libevent-client-c" title="Permalink to this headline">¶</a></h2>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="cm">/*</span>
|
||||
<span class="cm"> * nghttp2 - HTTP/2.0 C Library</span>
|
||||
<span class="cm"> * nghttp2 - HTTP/2 C Library</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Copyright (c) 2013 Tatsuhiro Tsujikawa</span>
|
||||
<span class="cm"> *</span>
|
||||
|
@ -808,7 +809,7 @@ here.</p>
|
|||
|
||||
<span class="cm">/* nghttp2_before_frame_send_callback: Called when nghttp2 library is</span>
|
||||
<span class="cm"> about to send a frame. We use this callback to get stream ID of new</span>
|
||||
<span class="cm"> stream. Since HEADERS in HTTP/2.0 has several roles, we check that</span>
|
||||
<span class="cm"> stream. Since HEADERS in HTTP/2 has several roles, we check that</span>
|
||||
<span class="cm"> it is a HTTP request HEADERS. */</span>
|
||||
<span class="k">static</span> <span class="kt">int</span> <span class="nf">before_frame_send_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="k">const</span> <span class="n">nghttp2_frame</span> <span class="o">*</span><span class="n">frame</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">)</span>
|
||||
|
@ -834,6 +835,7 @@ here.</p>
|
|||
<span class="k">const</span> <span class="n">nghttp2_frame</span> <span class="o">*</span><span class="n">frame</span><span class="p">,</span>
|
||||
<span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span><span class="n">name</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">namelen</span><span class="p">,</span>
|
||||
<span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span><span class="n">value</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">valuelen</span><span class="p">,</span>
|
||||
<span class="kt">uint8_t</span> <span class="n">flags</span><span class="p">,</span>
|
||||
<span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
<span class="n">http2_session_data</span> <span class="o">*</span><span class="n">session_data</span> <span class="o">=</span> <span class="p">(</span><span class="n">http2_session_data</span><span class="o">*</span><span class="p">)</span><span class="n">user_data</span><span class="p">;</span>
|
||||
|
@ -926,7 +928,7 @@ here.</p>
|
|||
<span class="p">}</span>
|
||||
|
||||
<span class="cm">/* NPN TLS extension client callback. We check that server advertised</span>
|
||||
<span class="cm"> the HTTP/2.0 protocol the nghttp2 library supports. If not, exit</span>
|
||||
<span class="cm"> the HTTP/2 protocol the nghttp2 library supports. If not, exit</span>
|
||||
<span class="cm"> the program. */</span>
|
||||
<span class="k">static</span> <span class="kt">int</span> <span class="nf">select_next_proto_cb</span><span class="p">(</span><span class="n">SSL</span><span class="o">*</span> <span class="n">ssl</span><span class="p">,</span>
|
||||
<span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">**</span><span class="n">out</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span><span class="n">outlen</span><span class="p">,</span>
|
||||
|
@ -989,8 +991,8 @@ here.</p>
|
|||
<span class="kt">int</span> <span class="n">rv</span><span class="p">;</span>
|
||||
|
||||
<span class="n">bufferevent_write</span><span class="p">(</span><span class="n">session_data</span><span class="o">-></span><span class="n">bev</span><span class="p">,</span>
|
||||
<span class="n">NGHTTP2_CLIENT_CONNECTION_HEADER</span><span class="p">,</span>
|
||||
<span class="n">NGHTTP2_CLIENT_CONNECTION_HEADER_LEN</span><span class="p">);</span>
|
||||
<span class="n">NGHTTP2_CLIENT_CONNECTION_PREFACE</span><span class="p">,</span>
|
||||
<span class="n">NGHTTP2_CLIENT_CONNECTION_PREFACE_LEN</span><span class="p">);</span>
|
||||
<span class="n">rv</span> <span class="o">=</span> <span class="n">nghttp2_submit_settings</span><span class="p">(</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="n">NGHTTP2_FLAG_NONE</span><span class="p">,</span>
|
||||
<span class="n">iv</span><span class="p">,</span> <span class="n">ARRLEN</span><span class="p">(</span><span class="n">iv</span><span class="p">));</span>
|
||||
<span class="k">if</span><span class="p">(</span><span class="n">rv</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
||||
|
@ -999,10 +1001,12 @@ here.</p>
|
|||
<span class="p">}</span>
|
||||
|
||||
<span class="cp">#define MAKE_NV(NAME, VALUE, VALUELEN) \</span>
|
||||
<span class="cp"> { (uint8_t*)NAME, (uint8_t*)VALUE, sizeof(NAME) - 1, VALUELEN }</span>
|
||||
<span class="cp"> { (uint8_t*)NAME, (uint8_t*)VALUE, sizeof(NAME) - 1, VALUELEN, \</span>
|
||||
<span class="cp"> NGHTTP2_NV_FLAG_NONE }</span>
|
||||
|
||||
<span class="cp">#define MAKE_NV2(NAME, VALUE) \</span>
|
||||
<span class="cp"> { (uint8_t*)NAME, (uint8_t*)VALUE, sizeof(NAME) - 1, sizeof(VALUE) - 1 }</span>
|
||||
<span class="cp"> { (uint8_t*)NAME, (uint8_t*)VALUE, sizeof(NAME) - 1, sizeof(VALUE) - 1, \</span>
|
||||
<span class="cp"> NGHTTP2_NV_FLAG_NONE }</span>
|
||||
|
||||
<span class="cm">/* Send HTTP request to the remote peer */</span>
|
||||
<span class="k">static</span> <span class="kt">void</span> <span class="nf">submit_request</span><span class="p">(</span><span class="n">http2_session_data</span> <span class="o">*</span><span class="n">session_data</span><span class="p">)</span>
|
||||
|
@ -1020,7 +1024,7 @@ here.</p>
|
|||
<span class="p">};</span>
|
||||
<span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">"Request headers:</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>
|
||||
<span class="n">print_headers</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="n">hdrs</span><span class="p">,</span> <span class="n">ARRLEN</span><span class="p">(</span><span class="n">hdrs</span><span class="p">));</span>
|
||||
<span class="n">rv</span> <span class="o">=</span> <span class="n">nghttp2_submit_request</span><span class="p">(</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="n">NGHTTP2_PRI_DEFAULT</span><span class="p">,</span>
|
||||
<span class="n">rv</span> <span class="o">=</span> <span class="n">nghttp2_submit_request</span><span class="p">(</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">,</span>
|
||||
<span class="n">hdrs</span><span class="p">,</span> <span class="n">ARRLEN</span><span class="p">(</span><span class="n">hdrs</span><span class="p">),</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">stream_data</span><span class="p">);</span>
|
||||
<span class="k">if</span><span class="p">(</span><span class="n">rv</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="n">errx</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="s">"Could not submit HTTP request: %s"</span><span class="p">,</span> <span class="n">nghttp2_strerror</span><span class="p">(</span><span class="n">rv</span><span class="p">));</span>
|
||||
|
@ -1206,10 +1210,10 @@ here.</p>
|
|||
|
||||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||||
|
||||
<a href="tutorial-server.html" class="btn btn-neutral float-right" title="Tutorial: HTTP/2.0 server"/>Next <span class="fa fa-arrow-circle-right"></span></a>
|
||||
<a href="tutorial-server.html" class="btn btn-neutral float-right" title="Tutorial: HTTP/2 server"/>Next <span class="fa fa-arrow-circle-right"></span></a>
|
||||
|
||||
|
||||
<a href="package_README.html" class="btn btn-neutral" title="nghttp2 - HTTP/2.0 C Library"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||||
<a href="package_README.html" class="btn btn-neutral" title="nghttp2 - HTTP/2 C Library"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Tutorial: HTTP/2.0 server — nghttp2 0.4.0-DEV documentation</title>
|
||||
<title>Tutorial: HTTP/2 server — nghttp2 0.4.0-DEV documentation</title>
|
||||
|
||||
|
||||
|
||||
|
@ -54,7 +54,7 @@
|
|||
|
||||
<link rel="top" title="nghttp2 0.4.0-DEV documentation" href="index.html"/>
|
||||
<link rel="next" title="API Reference" href="apiref.html"/>
|
||||
<link rel="prev" title="Tutorial: HTTP/2.0 client" href="tutorial-client.html"/>
|
||||
<link rel="prev" title="Tutorial: HTTP/2 client" href="tutorial-client.html"/>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
|||
|
||||
|
||||
<ul class="current">
|
||||
<li class="toctree-l1"><a class="reference internal" href="package_README.html">nghttp2 - HTTP/2.0 C Library</a><ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="package_README.html">nghttp2 - HTTP/2 C Library</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#development-status">Development Status</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#public-test-server">Public Test Server</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#requirements">Requirements</a></li>
|
||||
|
@ -93,11 +93,11 @@
|
|||
<li class="toctree-l2"><a class="reference internal" href="package_README.html#python-bindings">Python bindings</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="tutorial-client.html">Tutorial: HTTP/2.0 client</a><ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="tutorial-client.html">Tutorial: HTTP/2 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 current"><a class="current reference internal" href="">Tutorial: HTTP/2.0 server</a><ul>
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="">Tutorial: HTTP/2 server</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#libevent-server-c">libevent-server.c</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -137,7 +137,7 @@
|
|||
<ul class="wy-breadcrumbs">
|
||||
<li><a href="index.html">Docs</a> »</li>
|
||||
|
||||
<li>Tutorial: HTTP/2.0 server</li>
|
||||
<li>Tutorial: HTTP/2 server</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
</li>
|
||||
|
@ -146,10 +146,10 @@
|
|||
</div>
|
||||
<div role="main">
|
||||
|
||||
<div class="section" id="tutorial-http-2-0-server">
|
||||
<h1>Tutorial: HTTP/2.0 server<a class="headerlink" href="#tutorial-http-2-0-server" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="section" id="tutorial-http-2-server">
|
||||
<h1>Tutorial: HTTP/2 server<a class="headerlink" href="#tutorial-http-2-server" title="Permalink to this headline">¶</a></h1>
|
||||
<p>In this tutorial, we are going to write single-threaded, event-based
|
||||
HTTP/2.0 web server, which supports HTTPS only. It can handle
|
||||
HTTP/2 web server, which supports HTTPS only. It can handle
|
||||
concurrent multiple requests, but only GET method is supported. The
|
||||
complete source code, <a class="reference internal" href="#libevent-server-c">libevent-server.c</a>, is attached at the end of
|
||||
this page. It also resides in examples directory in the archive or
|
||||
|
@ -202,7 +202,7 @@ life time:</p>
|
|||
</div>
|
||||
<p>The wire format of NPN is a sequence of length prefixed string. The
|
||||
exactly one byte is used to specify the length of each protocol
|
||||
identifier. In this tutorial, we advertise the HTTP/2.0 protocol the
|
||||
identifier. In this tutorial, we advertise the HTTP/2 protocol the
|
||||
nghttp2 library supports. The nghttp2 library exports its identifier
|
||||
in <a class="reference internal" href="apiref.html#c.NGHTTP2_PROTO_VERSION_ID" title="NGHTTP2_PROTO_VERSION_ID"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_PROTO_VERSION_ID</span></tt></a>. The <tt class="docutils literal"><span class="pre">next_proto_cb()</span></tt> function
|
||||
is the server-side NPN callback. In OpenSSL implementation, we just
|
||||
|
@ -217,7 +217,7 @@ callback function is set to <tt class="docutils literal"><span class="pre">SSL_C
|
|||
</pre></div>
|
||||
</div>
|
||||
<p>We use <tt class="docutils literal"><span class="pre">http2_session_data</span></tt> structure to store the session-level
|
||||
(which corresponds to 1 HTTP/2.0 connection) data:</p>
|
||||
(which corresponds to 1 HTTP/2 connection) data:</p>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="k">typedef</span> <span class="k">struct</span> <span class="n">http2_session_data</span> <span class="p">{</span>
|
||||
<span class="k">struct</span> <span class="n">http2_stream_data</span> <span class="n">root</span><span class="p">;</span>
|
||||
<span class="k">struct</span> <span class="n">bufferevent</span> <span class="o">*</span><span class="n">bev</span><span class="p">;</span>
|
||||
|
@ -238,19 +238,20 @@ data:</p>
|
|||
<span class="p">}</span> <span class="n">http2_stream_data</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>1 HTTP/2.0 session can have multiple streams. We manage these
|
||||
multiple streams by intrusive doubly linked list to add and remove the
|
||||
object in O(1). The first element of this list is pointed by the
|
||||
<p>1 HTTP/2 session can have multiple streams. We manage these multiple
|
||||
streams by intrusive doubly linked list to add and remove the object
|
||||
in O(1). The first element of this list is pointed by the
|
||||
<tt class="docutils literal"><span class="pre">root->next</span></tt> in <tt class="docutils literal"><span class="pre">http2_session_data</span></tt>. Initially, <tt class="docutils literal"><span class="pre">root->next</span></tt>
|
||||
is <tt class="docutils literal"><span class="pre">NULL</span></tt>. The <tt class="docutils literal"><span class="pre">handshake_leftlen</span></tt> member of
|
||||
<tt class="docutils literal"><span class="pre">http2_session_data</span></tt> is used to track the number of bytes remaining
|
||||
when receiving first 24 bytes magic value
|
||||
(<a class="reference internal" href="apiref.html#c.NGHTTP2_CLIENT_CONNECTION_HEADER" title="NGHTTP2_CLIENT_CONNECTION_HEADER"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_CLIENT_CONNECTION_HEADER</span></tt></a>) from the client. We use
|
||||
libevent’s bufferevent structure to perform network I/O. Notice that
|
||||
bufferevent object is in <tt class="docutils literal"><span class="pre">http2_session_data</span></tt> and not in
|
||||
<tt class="docutils literal"><span class="pre">http2_stream_data</span></tt>. This is because <tt class="docutils literal"><span class="pre">http2_stream_data</span></tt> is just a
|
||||
logical stream multiplexed over the single connection managed by
|
||||
bufferevent in <tt class="docutils literal"><span class="pre">http2_session_data</span></tt>.</p>
|
||||
when receiving first client connection preface
|
||||
(<a class="reference internal" href="apiref.html#c.NGHTTP2_CLIENT_CONNECTION_PREFACE" title="NGHTTP2_CLIENT_CONNECTION_PREFACE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_CLIENT_CONNECTION_PREFACE</span></tt></a>), which is 24 bytes magic
|
||||
byte string, from the client. We use libevent’s bufferevent structure
|
||||
to perform network I/O. Notice that bufferevent object is in
|
||||
<tt class="docutils literal"><span class="pre">http2_session_data</span></tt> and not in <tt class="docutils literal"><span class="pre">http2_stream_data</span></tt>. This is
|
||||
because <tt class="docutils literal"><span class="pre">http2_stream_data</span></tt> is just a logical stream multiplexed
|
||||
over the single connection managed by bufferevent in
|
||||
<tt class="docutils literal"><span class="pre">http2_session_data</span></tt>.</p>
|
||||
<p>We first create listener object to accept incoming connections.
|
||||
We use libevent’s <tt class="docutils literal"><span class="pre">struct</span> <span class="pre">evconnlistener</span></tt> for this purpose:</p>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="k">static</span> <span class="kt">void</span> <span class="nf">start_listen</span><span class="p">(</span><span class="k">struct</span> <span class="n">event_base</span> <span class="o">*</span><span class="n">evbase</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">service</span><span class="p">,</span>
|
||||
|
@ -340,9 +341,9 @@ it:</p>
|
|||
<span class="kt">uint8_t</span> <span class="n">data</span><span class="p">[</span><span class="mi">24</span><span class="p">];</span>
|
||||
<span class="k">struct</span> <span class="n">evbuffer</span> <span class="o">*</span><span class="n">input</span> <span class="o">=</span> <span class="n">bufferevent_get_input</span><span class="p">(</span><span class="n">session_data</span><span class="o">-></span><span class="n">bev</span><span class="p">);</span>
|
||||
<span class="kt">int</span> <span class="n">readlen</span> <span class="o">=</span> <span class="n">evbuffer_remove</span><span class="p">(</span><span class="n">input</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">session_data</span><span class="o">-></span><span class="n">handshake_leftlen</span><span class="p">);</span>
|
||||
<span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">conhead</span> <span class="o">=</span> <span class="n">NGHTTP2_CLIENT_CONNECTION_HEADER</span><span class="p">;</span>
|
||||
<span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">conhead</span> <span class="o">=</span> <span class="n">NGHTTP2_CLIENT_CONNECTION_PREFACE</span><span class="p">;</span>
|
||||
|
||||
<span class="k">if</span><span class="p">(</span><span class="n">memcmp</span><span class="p">(</span><span class="n">conhead</span> <span class="o">+</span> <span class="n">NGHTTP2_CLIENT_CONNECTION_HEADER_LEN</span>
|
||||
<span class="k">if</span><span class="p">(</span><span class="n">memcmp</span><span class="p">(</span><span class="n">conhead</span> <span class="o">+</span> <span class="n">NGHTTP2_CLIENT_CONNECTION_PREFACE_LEN</span>
|
||||
<span class="o">-</span> <span class="n">session_data</span><span class="o">-></span><span class="n">handshake_leftlen</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">readlen</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="n">delete_http2_session_data</span><span class="p">(</span><span class="n">session_data</span><span class="p">);</span>
|
||||
<span class="k">return</span><span class="p">;</span>
|
||||
|
@ -366,11 +367,11 @@ it:</p>
|
|||
</pre></div>
|
||||
</div>
|
||||
<p>We check that the received byte string matches
|
||||
<a class="reference internal" href="apiref.html#c.NGHTTP2_CLIENT_CONNECTION_HEADER" title="NGHTTP2_CLIENT_CONNECTION_HEADER"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_CLIENT_CONNECTION_HEADER</span></tt></a>. When they match, the
|
||||
connection state is ready for starting HTTP/2.0 communication. First
|
||||
<a class="reference internal" href="apiref.html#c.NGHTTP2_CLIENT_CONNECTION_PREFACE" title="NGHTTP2_CLIENT_CONNECTION_PREFACE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_CLIENT_CONNECTION_PREFACE</span></tt></a>. When they match, the
|
||||
connection state is ready for starting HTTP/2 communication. First
|
||||
we change the callback functions for the bufferevent object. We use
|
||||
same <tt class="docutils literal"><span class="pre">eventcb</span></tt> as before. But we specify new <tt class="docutils literal"><span class="pre">readcb</span></tt> and
|
||||
<tt class="docutils literal"><span class="pre">writecb</span></tt> function to handle HTTP/2.0 communication. We describe
|
||||
<tt class="docutils literal"><span class="pre">writecb</span></tt> function to handle HTTP/2 communication. We describe
|
||||
these 2 functions later.</p>
|
||||
<p>We initialize nghttp2 session object which is done in
|
||||
<tt class="docutils literal"><span class="pre">initialize_nghttp2_session()</span></tt>:</p>
|
||||
|
@ -568,7 +569,7 @@ of header block in HEADERS or PUSH_PROMISE frame is started:</p>
|
|||
</pre></div>
|
||||
</div>
|
||||
<p>We only interested in HEADERS frame in this function. Since HEADERS
|
||||
frame has several roles in HTTP/2.0 protocol, we check that it is a
|
||||
frame has several roles in HTTP/2 protocol, we check that it is a
|
||||
request HEADERS, which opens new stream. If frame is request HEADERS,
|
||||
then we create <tt class="docutils literal"><span class="pre">http2_stream_data</span></tt> object to store stream related
|
||||
data. We associate created <tt class="docutils literal"><span class="pre">http2_stream_data</span></tt> object to the stream
|
||||
|
@ -673,7 +674,7 @@ file descriptor. We also set <tt class="docutils literal"><span class="pre">file
|
|||
function to read content of the file:</p>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="k">static</span> <span class="kt">ssize_t</span> <span class="nf">file_read_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="kt">int32_t</span> <span class="n">stream_id</span><span class="p">,</span>
|
||||
<span class="kt">uint8_t</span> <span class="o">*</span><span class="n">buf</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">length</span><span class="p">,</span> <span class="kt">int</span> <span class="o">*</span><span class="n">eof</span><span class="p">,</span>
|
||||
<span class="kt">uint8_t</span> <span class="o">*</span><span class="n">buf</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">length</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">data_flags</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_data_source</span> <span class="o">*</span><span class="n">source</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
<span class="kt">int</span> <span class="n">fd</span> <span class="o">=</span> <span class="n">source</span><span class="o">-></span><span class="n">fd</span><span class="p">;</span>
|
||||
|
@ -683,17 +684,17 @@ function to read content of the file:</p>
|
|||
<span class="k">return</span> <span class="n">NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE</span><span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
<span class="k">if</span><span class="p">(</span><span class="n">r</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="o">*</span><span class="n">eof</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
|
||||
<span class="o">*</span><span class="n">data_flags</span> <span class="o">|=</span> <span class="n">NGHTTP2_DATA_FLAG_EOF</span><span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
<span class="k">return</span> <span class="n">r</span><span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>If error happens while reading file, we return
|
||||
<a class="reference internal" href="apiref.html#c.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE" title="NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE</span></tt></a>. This tells the library
|
||||
to send RST_STREAM to the stream. When all data is read, set 1 to
|
||||
<tt class="docutils literal"><span class="pre">*eof</span></tt> to tell the nghttp2 library that we have finished reading
|
||||
file.</p>
|
||||
<a class="reference internal" href="apiref.html#c.NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE" title="NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE</span></tt></a>. This tells the
|
||||
library to send RST_STREAM to the stream. When all data are read, set
|
||||
<a class="reference internal" href="apiref.html#c.NGHTTP2_DATA_FLAG_EOF" title="NGHTTP2_DATA_FLAG_EOF"><tt class="xref c c-macro docutils literal"><span class="pre">NGHTTP2_DATA_FLAG_EOF</span></tt></a> flag to <tt class="docutils literal"><span class="pre">*data_flags</span></tt> to tell the
|
||||
nghttp2 library that we have finished reading file.</p>
|
||||
<p>The <a class="reference internal" href="apiref.html#c.nghttp2_submit_response" title="nghttp2_submit_response"><tt class="xref c c-func docutils literal"><span class="pre">nghttp2_submit_response()</span></tt></a> is used to send response to the remote
|
||||
peer.</p>
|
||||
<p>The <tt class="docutils literal"><span class="pre">on_stream_close_callback()</span></tt> function is invoked when the stream
|
||||
|
@ -721,7 +722,7 @@ stream is about to close and we no longer use that object.</p>
|
|||
<div class="section" id="libevent-server-c">
|
||||
<h2>libevent-server.c<a class="headerlink" href="#libevent-server-c" title="Permalink to this headline">¶</a></h2>
|
||||
<div class="highlight-c"><div class="highlight"><pre><span class="cm">/*</span>
|
||||
<span class="cm"> * nghttp2 - HTTP/2.0 C Library</span>
|
||||
<span class="cm"> * nghttp2 - HTTP/2 C Library</span>
|
||||
<span class="cm"> *</span>
|
||||
<span class="cm"> * Copyright (c) 2013 Tatsuhiro Tsujikawa</span>
|
||||
<span class="cm"> *</span>
|
||||
|
@ -771,7 +772,8 @@ stream is about to close and we no longer use that object.</p>
|
|||
<span class="cp">#define ARRLEN(x) (sizeof(x)/sizeof(x[0]))</span>
|
||||
|
||||
<span class="cp">#define MAKE_NV(NAME, VALUE) \</span>
|
||||
<span class="cp"> { (uint8_t*)NAME, (uint8_t*)VALUE, sizeof(NAME) - 1, sizeof(VALUE) - 1 }</span>
|
||||
<span class="cp"> { (uint8_t*)NAME, (uint8_t*)VALUE, sizeof(NAME) - 1, sizeof(VALUE) - 1, \</span>
|
||||
<span class="cp"> NGHTTP2_NV_FLAG_NONE }</span>
|
||||
|
||||
<span class="k">struct</span> <span class="n">app_context</span><span class="p">;</span>
|
||||
<span class="k">typedef</span> <span class="k">struct</span> <span class="n">app_context</span> <span class="n">app_context</span><span class="p">;</span>
|
||||
|
@ -912,7 +914,7 @@ stream is about to close and we no longer use that object.</p>
|
|||
<span class="p">(</span><span class="n">app_ctx</span><span class="o">-></span><span class="n">evbase</span><span class="p">,</span> <span class="n">fd</span><span class="p">,</span> <span class="n">ssl</span><span class="p">,</span>
|
||||
<span class="n">BUFFEREVENT_SSL_ACCEPTING</span><span class="p">,</span>
|
||||
<span class="n">BEV_OPT_CLOSE_ON_FREE</span> <span class="o">|</span> <span class="n">BEV_OPT_DEFER_CALLBACKS</span><span class="p">);</span>
|
||||
<span class="n">session_data</span><span class="o">-></span><span class="n">handshake_leftlen</span> <span class="o">=</span> <span class="n">NGHTTP2_CLIENT_CONNECTION_HEADER_LEN</span><span class="p">;</span>
|
||||
<span class="n">session_data</span><span class="o">-></span><span class="n">handshake_leftlen</span> <span class="o">=</span> <span class="n">NGHTTP2_CLIENT_CONNECTION_PREFACE_LEN</span><span class="p">;</span>
|
||||
<span class="n">rv</span> <span class="o">=</span> <span class="n">getnameinfo</span><span class="p">(</span><span class="n">addr</span><span class="p">,</span> <span class="n">addrlen</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">host</span><span class="p">),</span> <span class="nb">NULL</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">NI_NUMERICHOST</span><span class="p">);</span>
|
||||
<span class="k">if</span><span class="p">(</span><span class="n">rv</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="n">session_data</span><span class="o">-></span><span class="n">client_addr</span> <span class="o">=</span> <span class="n">strdup</span><span class="p">(</span><span class="s">"(unknown)"</span><span class="p">);</span>
|
||||
|
@ -1049,7 +1051,7 @@ stream is about to close and we no longer use that object.</p>
|
|||
|
||||
<span class="k">static</span> <span class="kt">ssize_t</span> <span class="nf">file_read_callback</span>
|
||||
<span class="p">(</span><span class="n">nghttp2_session</span> <span class="o">*</span><span class="n">session</span><span class="p">,</span> <span class="kt">int32_t</span> <span class="n">stream_id</span><span class="p">,</span>
|
||||
<span class="kt">uint8_t</span> <span class="o">*</span><span class="n">buf</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">length</span><span class="p">,</span> <span class="kt">int</span> <span class="o">*</span><span class="n">eof</span><span class="p">,</span>
|
||||
<span class="kt">uint8_t</span> <span class="o">*</span><span class="n">buf</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">length</span><span class="p">,</span> <span class="kt">uint32_t</span> <span class="o">*</span><span class="n">data_flags</span><span class="p">,</span>
|
||||
<span class="n">nghttp2_data_source</span> <span class="o">*</span><span class="n">source</span><span class="p">,</span> <span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
<span class="kt">int</span> <span class="n">fd</span> <span class="o">=</span> <span class="n">source</span><span class="o">-></span><span class="n">fd</span><span class="p">;</span>
|
||||
|
@ -1059,7 +1061,7 @@ stream is about to close and we no longer use that object.</p>
|
|||
<span class="k">return</span> <span class="n">NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE</span><span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
<span class="k">if</span><span class="p">(</span><span class="n">r</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="o">*</span><span class="n">eof</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
|
||||
<span class="o">*</span><span class="n">data_flags</span> <span class="o">|=</span> <span class="n">NGHTTP2_DATA_FLAG_EOF</span><span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
<span class="k">return</span> <span class="n">r</span><span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
|
@ -1121,6 +1123,7 @@ stream is about to close and we no longer use that object.</p>
|
|||
<span class="k">const</span> <span class="n">nghttp2_frame</span> <span class="o">*</span><span class="n">frame</span><span class="p">,</span>
|
||||
<span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span><span class="n">name</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">namelen</span><span class="p">,</span>
|
||||
<span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span><span class="n">value</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">valuelen</span><span class="p">,</span>
|
||||
<span class="kt">uint8_t</span> <span class="n">flags</span><span class="p">,</span>
|
||||
<span class="kt">void</span> <span class="o">*</span><span class="n">user_data</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
<span class="n">http2_stream_data</span> <span class="o">*</span><span class="n">stream_data</span><span class="p">;</span>
|
||||
|
@ -1271,7 +1274,7 @@ stream is about to close and we no longer use that object.</p>
|
|||
<span class="n">nghttp2_session_server_new</span><span class="p">(</span><span class="o">&</span><span class="n">session_data</span><span class="o">-></span><span class="n">session</span><span class="p">,</span> <span class="o">&</span><span class="n">callbacks</span><span class="p">,</span> <span class="n">session_data</span><span class="p">);</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="cm">/* Send HTTP/2.0 client connection header, which includes 24 bytes</span>
|
||||
<span class="cm">/* Send HTTP/2 client connection header, which includes 24 bytes</span>
|
||||
<span class="cm"> magic octets and SETTINGS frame */</span>
|
||||
<span class="k">static</span> <span class="kt">int</span> <span class="nf">send_server_connection_header</span><span class="p">(</span><span class="n">http2_session_data</span> <span class="o">*</span><span class="n">session_data</span><span class="p">)</span>
|
||||
<span class="p">{</span>
|
||||
|
@ -1351,9 +1354,9 @@ stream is about to close and we no longer use that object.</p>
|
|||
<span class="kt">uint8_t</span> <span class="n">data</span><span class="p">[</span><span class="mi">24</span><span class="p">];</span>
|
||||
<span class="k">struct</span> <span class="n">evbuffer</span> <span class="o">*</span><span class="n">input</span> <span class="o">=</span> <span class="n">bufferevent_get_input</span><span class="p">(</span><span class="n">session_data</span><span class="o">-></span><span class="n">bev</span><span class="p">);</span>
|
||||
<span class="kt">int</span> <span class="n">readlen</span> <span class="o">=</span> <span class="n">evbuffer_remove</span><span class="p">(</span><span class="n">input</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">session_data</span><span class="o">-></span><span class="n">handshake_leftlen</span><span class="p">);</span>
|
||||
<span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">conhead</span> <span class="o">=</span> <span class="n">NGHTTP2_CLIENT_CONNECTION_HEADER</span><span class="p">;</span>
|
||||
<span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">conhead</span> <span class="o">=</span> <span class="n">NGHTTP2_CLIENT_CONNECTION_PREFACE</span><span class="p">;</span>
|
||||
|
||||
<span class="k">if</span><span class="p">(</span><span class="n">memcmp</span><span class="p">(</span><span class="n">conhead</span> <span class="o">+</span> <span class="n">NGHTTP2_CLIENT_CONNECTION_HEADER_LEN</span>
|
||||
<span class="k">if</span><span class="p">(</span><span class="n">memcmp</span><span class="p">(</span><span class="n">conhead</span> <span class="o">+</span> <span class="n">NGHTTP2_CLIENT_CONNECTION_PREFACE_LEN</span>
|
||||
<span class="o">-</span> <span class="n">session_data</span><span class="o">-></span><span class="n">handshake_leftlen</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">readlen</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
|
||||
<span class="n">delete_http2_session_data</span><span class="p">(</span><span class="n">session_data</span><span class="p">);</span>
|
||||
<span class="k">return</span><span class="p">;</span>
|
||||
|
@ -1478,7 +1481,7 @@ stream is about to close and we no longer use that object.</p>
|
|||
<a href="apiref.html" class="btn btn-neutral float-right" title="API Reference"/>Next <span class="fa fa-arrow-circle-right"></span></a>
|
||||
|
||||
|
||||
<a href="tutorial-client.html" class="btn btn-neutral" title="Tutorial: HTTP/2.0 client"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||||
<a href="tutorial-client.html" class="btn btn-neutral" title="Tutorial: HTTP/2 client"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue