Coder Social home page Coder Social logo

nghttp2 / nghttp2 Goto Github PK

View Code? Open in Web Editor NEW
4.6K 4.6K 860.0 36.6 MB

nghttp2 - HTTP/2 C Library and tools

Home Page: https://nghttp2.org

License: Other

Shell 0.21% C++ 50.33% C 39.76% Python 1.97% Go 3.94% Ruby 0.01% Makefile 0.52% CMake 1.46% M4 1.63% Dockerfile 0.15%
c cpp20 http2 http3 quic

nghttp2's Introduction

nghttp2 - HTTP/2 C Library

This is an implementation of the Hypertext Transfer Protocol version 2 in C.

The framing layer of HTTP/2 is implemented as a reusable C library. On top of that, we have implemented an HTTP/2 client, server and proxy. We have also developed load test and benchmarking tools for HTTP/2.

An HPACK encoder and decoder are available as a public API.

Development Status

nghttp2 was originally developed based on RFC 7540 HTTP/2 and RFC 7541 HPACK - Header Compression for HTTP/2. Now we are updating our code to implement RFC 9113.

The nghttp2 code base was forked from the spdylay (https://github.com/tatsuhiro-t/spdylay) project.

Public Test Server

The following endpoints are available to try out our nghttp2 implementation.

  • https://nghttp2.org/ (TLS + ALPN and HTTP/3)

    This endpoint supports h2, h2-16, h2-14, and http/1.1 via ALPN and requires TLSv1.2 for HTTP/2 connection.

    It also supports HTTP/3.

  • http://nghttp2.org/ (HTTP Upgrade and HTTP/2 Direct)

    h2c and http/1.1.

Requirements

The following package is required to build the libnghttp2 library:

  • pkg-config >= 0.20

To build the documentation, you need to install:

If you need libnghttp2 (C library) only, then the above packages are all you need. Use --enable-lib-only to ensure that only libnghttp2 is built. This avoids potential build error related to building bundled applications.

To build and run the application programs (nghttp, nghttpd, nghttpx and h2load) in the src directory, the following packages are required:

  • OpenSSL >= 1.1.1; or wolfSSL >= 5.7.0; or LibreSSL >= 3.8.1; or aws-lc >= 1.19.0; or BoringSSL
  • libev >= 4.11
  • zlib >= 1.2.3
  • libc-ares >= 1.7.5

To enable -a option (getting linked assets from the downloaded resource) in nghttp, the following package is required:

  • libxml2 >= 2.6.26

To enable systemd support in nghttpx, the following package is required:

  • libsystemd-dev >= 209

The HPACK tools require the following package:

  • jansson >= 2.5

To build sources under the examples directory, libevent is required:

  • libevent-openssl >= 2.0.8

To mitigate heap fragmentation in long running server programs (nghttpd and nghttpx), jemalloc is recommended:

  • jemalloc

    Note

    Alpine Linux currently does not support malloc replacement due to musl limitations. See details in issue #762.

For BoringSSL or aws-lc build, to enable RFC 8879 TLS Certificate Compression in applications, the following library is required:

  • libbrotli-dev >= 1.0.9

To enable mruby support for nghttpx, mruby is required. We need to build mruby with C++ ABI explicitly turned on, and probably need other mrgems, mruby is managed by git submodule under third-party/mruby directory. Currently, mruby support for nghttpx is disabled by default. To enable mruby support, use --with-mruby configure option. Note that at the time of this writing, libmruby-dev and mruby packages in Debian/Ubuntu are not usable for nghttp2, since they do not enable C++ ABI. To build mruby, the following packages are required:

  • ruby
  • bison

nghttpx supports neverbleed, privilege separation engine for OpenSSL. In short, it minimizes the risk of private key leakage when serious bug like Heartbleed is exploited. The neverbleed is disabled by default. To enable it, use --with-neverbleed configure option.

To enable the experimental HTTP/3 support for h2load and nghttpx, the following libraries are required:

Use --enable-http3 configure option to enable HTTP/3 feature for h2load and nghttpx.

In order to build optional eBPF program to direct an incoming QUIC UDP datagram to a correct socket for nghttpx, the following libraries are required:

  • libbpf-dev >= 0.7.0

Use --with-libbpf configure option to build eBPF program. libelf-dev is needed to build libbpf.

For Ubuntu 20.04, you can build libbpf from the source code. nghttpx requires eBPF program for reloading its configuration and hot swapping its executable.

Compiling libnghttp2 C source code requires a C99 compiler. gcc 4.8 is known to be adequate. In order to compile the C++ source code, C++20 compliant compiler is required. At least g++ >= 12 and clang++ >= 15 are known to work.

Note

To enable mruby support in nghttpx, and use --with-mruby configure option.

Note

Mac OS X users may need the --disable-threads configure option to disable multi-threading in nghttpd, nghttpx and h2load to prevent them from crashing. A patch is welcome to make multi threading work on Mac OS X platform.

Note

To compile the associated applications (nghttp, nghttpd, nghttpx and h2load), you must use the --enable-app configure option and ensure that the specified requirements above are met. Normally, configure script checks required dependencies to build these applications, and enable --enable-app automatically, so you don't have to use it explicitly. But if you found that applications were not built, then using --enable-app may find that cause, such as the missing dependency.

Note

In order to detect third party libraries, pkg-config is used (however we don't use pkg-config for some libraries (e.g., libev)). By default, pkg-config searches *.pc file in the standard locations (e.g., /usr/lib/pkgconfig). If it is necessary to use *.pc file in the custom location, specify paths to PKG_CONFIG_PATH environment variable, and pass it to configure script, like so:

$ ./configure PKG_CONFIG_PATH=/path/to/pkgconfig

For pkg-config managed libraries, *_CFLAG and *_LIBS environment variables are defined (e.g., OPENSSL_CFLAGS, OPENSSL_LIBS). Specifying non-empty string to these variables completely overrides pkg-config. In other words, if they are specified, pkg-config is not used for detection, and user is responsible to specify the correct values to these variables. For complete list of these variables, run ./configure -h.

If you are using Ubuntu 22.04 LTS, run the following to install the required packages:

sudo apt-get install g++ clang make binutils autoconf automake \
  autotools-dev libtool pkg-config \
  zlib1g-dev libssl-dev libxml2-dev libev-dev \
  libevent-dev libjansson-dev \
  libc-ares-dev libjemalloc-dev libsystemd-dev \
  ruby-dev bison libelf-dev

Building nghttp2 from release tar archive

The nghttp2 project regularly releases tar archives which includes nghttp2 source code, and generated build files. They can be downloaded from Releases page.

Building nghttp2 from git requires autotools development packages. Building from tar archives does not require them, and thus it is much easier. The usual build step is as follows:

$ tar xf nghttp2-X.Y.Z.tar.bz2
$ cd nghttp2-X.Y.Z
$ ./configure
$ make

Building from git

Building from git is easy, but please be sure that at least autoconf 2.68 is used:

$ git submodule update --init
$ autoreconf -i
$ automake
$ autoconf
$ ./configure
$ make

Notes for building on Windows (MSVC)

The easiest way to build native Windows nghttp2 dll is use cmake. The free version of Visual C++ Build Tools works fine.

  1. Install cmake for windows
  2. Open "Visual C++ ... Native Build Tool Command Prompt", and inside nghttp2 directly, run cmake.
  3. Then run cmake --build to build library.
  4. nghttp2.dll, nghttp2.lib, nghttp2.exp are placed under lib directory.

Note that the above steps most likely produce nghttp2 library only. No bundled applications are compiled.

Notes for building on Windows (Mingw/Cygwin)

Under Mingw environment, you can only compile the library, it's libnghttp2-X.dll and libnghttp2.a.

If you want to compile the applications(h2load, nghttp, nghttpx, nghttpd), you need to use the Cygwin environment.

Under Cygwin environment, to compile the applications you need to compile and install the libev first.

Secondly, you need to undefine the macro __STRICT_ANSI__, if you not, the functions fdopen, fileno and strptime will not available.

the sample command like this:

$ export CFLAGS="-U__STRICT_ANSI__ -I$libev_PREFIX/include -L$libev_PREFIX/lib"
$ export CXXFLAGS=$CFLAGS
$ ./configure
$ make

If you want to compile the applications under examples/, you need to remove or rename the event.h from libev's installation, because it conflicts with libevent's installation.

Notes for installation on Linux systems

After installing nghttp2 tool suite with make install one might experience a similar error:

nghttpx: error while loading shared libraries: libnghttp2.so.14: cannot open shared object file: No such file or directory

This means that the tool is unable to locate the libnghttp2.so shared library.

To update the shared library cache run sudo ldconfig.

Building the documentation

Note

Documentation is still incomplete.

To build the documentation, run:

$ make html

The documents will be generated under doc/manual/html/.

The generated documents will not be installed with make install.

The online documentation is available at https://nghttp2.org/documentation/

Build HTTP/3 enabled h2load and nghttpx

To build h2load and nghttpx with HTTP/3 feature enabled, run the configure script with --enable-http3.

For nghttpx to reload configurations and swapping its executable while gracefully terminating old worker processes, eBPF is required. Run the configure script with --enable-http3 --with-libbpf to build eBPF program. The QUIC keying material must be set with --frontend-quic-secret-file in order to keep the existing connections alive during reload.

The detailed steps to build HTTP/3 enabled h2load and nghttpx follow.

Build aws-lc:

$ git clone --depth 1 -b v1.26.0 https://github.com/aws/aws-lc
$ cd aws-lc
$ cmake -B build -DDISABLE_GO=ON --install-prefix=$PWD/opt
$ make -j$(nproc) -C build
$ cmake --install build
$ cd ..

Build nghttp3:

$ git clone --depth 1 -b v1.4.0 https://github.com/ngtcp2/nghttp3
$ cd nghttp3
$ git submodule update --init --depth 1
$ autoreconf -i
$ ./configure --prefix=$PWD/build --enable-lib-only
$ make -j$(nproc)
$ make install
$ cd ..

Build ngtcp2:

$ git clone --depth 1 -b v1.6.0 https://github.com/ngtcp2/ngtcp2
$ cd ngtcp2
$ git submodule update --init --depth 1
$ autoreconf -i
$ ./configure --prefix=$PWD/build --enable-lib-only --with-boringssl \
      BORINGSSL_CFLAGS="-I$PWD/../aws-lc/opt/include" \
      BORINGSSL_LIBS="-L$PWD/../aws-lc/opt/lib -lssl -lcrypto"
$ make -j$(nproc)
$ make install
$ cd ..

If your Linux distribution does not have libbpf-dev >= 0.7.0, build from source:

$ git clone --depth 1 -b v1.4.2 https://github.com/libbpf/libbpf
$ cd libbpf
$ PREFIX=$PWD/build make -C src install
$ cd ..

Build nghttp2:

$ git clone https://github.com/nghttp2/nghttp2
$ cd nghttp2
$ git submodule update --init
$ autoreconf -i
$ ./configure --with-mruby --enable-http3 --with-libbpf \
      CC=clang-15 CXX=clang++-15 \
      PKG_CONFIG_PATH="$PWD/../aws-lc/opt/lib/pkgconfig:$PWD/../nghttp3/build/lib/pkgconfig:$PWD/../ngtcp2/build/lib/pkgconfig:$PWD/../libbpf/build/lib64/pkgconfig" \
      LDFLAGS="$LDFLAGS -Wl,-rpath,$PWD/../aws-lc/opt/lib -Wl,-rpath,$PWD/../libbpf/build/lib64"
$ make -j$(nproc)

The eBPF program reuseport_kern.o should be found under bpf directory. Pass --quic-bpf-program-file=bpf/reuseport_kern.o option to nghttpx to load it. See also HTTP/3 section in nghttpx - HTTP/2 proxy - HOW-TO.

Unit tests

Unit tests are done by simply running make check.

Integration tests

We have the integration tests for the nghttpx proxy server. The tests are written in the Go programming language and uses its testing framework. We depend on the following libraries:

Go modules will download these dependencies automatically.

To run the tests, run the following command under integration-tests directory:

$ make it

Inside the tests, we use port 3009 to run the test subject server.

Migration from v0.7.15 or earlier

nghttp2 v1.0.0 introduced several backward incompatible changes. In this section, we describe these changes and how to migrate to v1.0.0.

ALPN protocol ID is now h2 and h2c

Previously we announced h2-14 and h2c-14. v1.0.0 implements final protocol version, and we changed ALPN ID to h2 and h2c. The macros NGHTTP2_PROTO_VERSION_ID, NGHTTP2_PROTO_VERSION_ID_LEN, NGHTTP2_CLEARTEXT_PROTO_VERSION_ID, and NGHTTP2_CLEARTEXT_PROTO_VERSION_ID_LEN have been updated to reflect this change.

Basically, existing applications do not have to do anything, just recompiling is enough for this change.

Use word "client magic" where we use "client connection preface"

We use "client connection preface" to mean first 24 bytes of client connection preface. This is technically not correct, since client connection preface is composed of 24 bytes client magic byte string followed by SETTINGS frame. For clarification, we call "client magic" for this 24 bytes byte string and updated API.

  • NGHTTP2_CLIENT_CONNECTION_PREFACE was replaced with NGHTTP2_CLIENT_MAGIC.
  • NGHTTP2_CLIENT_CONNECTION_PREFACE_LEN was replaced with NGHTTP2_CLIENT_MAGIC_LEN.
  • NGHTTP2_BAD_PREFACE was renamed as NGHTTP2_BAD_CLIENT_MAGIC

The already deprecated NGHTTP2_CLIENT_CONNECTION_HEADER and NGHTTP2_CLIENT_CONNECTION_HEADER_LEN were removed.

If application uses these macros, just replace old ones with new ones. Since v1.0.0, client magic is sent by library (see next subsection), so client application may just remove these macro use.

Client magic is sent by library

Previously nghttp2 library did not send client magic, which is first 24 bytes byte string of client connection preface, and client applications have to send it by themselves. Since v1.0.0, client magic is sent by library via first call of nghttp2_session_send() or nghttp2_session_mem_send2().

The client applications which send client magic must remove the relevant code.

Remove HTTP Alternative Services (Alt-Svc) related code

Alt-Svc specification is not finalized yet. To make our API stable, we have decided to remove all Alt-Svc related API from nghttp2.

  • NGHTTP2_EXT_ALTSVC was removed.
  • nghttp2_ext_altsvc was removed.

We have already removed the functionality of Alt-Svc in v0.7 series and they have been essentially noop. The application using these macro and struct, remove those lines.

Use nghttp2_error in nghttp2_on_invalid_frame_recv_callback

Previously nghttp2_on_invalid_frame_recv_cb_called took the error_code, defined in nghttp2_error_code, as parameter. But they are not detailed enough to debug. Therefore, we decided to use more detailed nghttp2_error values instead.

The application using this callback should update the callback signature. If it treats error_code as HTTP/2 error code, update the code so that it is treated as nghttp2_error.

Receive client magic by default

Previously nghttp2 did not process client magic (24 bytes byte string). To make it deal with it, we had to use nghttp2_option_set_recv_client_preface(). Since v1.0.0, nghttp2 processes client magic by default and nghttp2_option_set_recv_client_preface() was removed.

Some application may want to disable this behaviour, so we added nghttp2_option_set_no_recv_client_magic() to achieve this.

The application using nghttp2_option_set_recv_client_preface() with nonzero value, just remove it.

The application using nghttp2_option_set_recv_client_preface() with zero value or not using it must use nghttp2_option_set_no_recv_client_magic() with nonzero value.

Client, Server and Proxy programs

The src directory contains the HTTP/2 client, server and proxy programs.

nghttp - client

nghttp is a HTTP/2 client. It can connect to the HTTP/2 server with prior knowledge, HTTP Upgrade and ALPN TLS extension.

It has verbose output mode for framing information. Here is sample output from nghttp client:

$ nghttp -nv https://nghttp2.org
[  0.190] Connected
The negotiated protocol: h2
[  0.212] recv SETTINGS frame <length=12, flags=0x00, stream_id=0>
          (niv=2)
          [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
          [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.212] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
          (niv=2)
          [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
          [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.212] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
          ; ACK
          (niv=0)
[  0.212] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
          (dep_stream_id=0, weight=201, exclusive=0)
[  0.212] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
          (dep_stream_id=0, weight=101, exclusive=0)
[  0.212] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
          (dep_stream_id=0, weight=1, exclusive=0)
[  0.212] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
          (dep_stream_id=7, weight=1, exclusive=0)
[  0.212] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
          (dep_stream_id=3, weight=1, exclusive=0)
[  0.212] send HEADERS frame <length=39, flags=0x25, stream_id=13>
          ; END_STREAM | END_HEADERS | PRIORITY
          (padlen=0, dep_stream_id=11, weight=16, exclusive=0)
          ; Open new stream
          :method: GET
          :path: /
          :scheme: https
          :authority: nghttp2.org
          accept: */*
          accept-encoding: gzip, deflate
          user-agent: nghttp2/1.0.1-DEV
[  0.221] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
          ; ACK
          (niv=0)
[  0.221] recv (stream_id=13) :method: GET
[  0.221] recv (stream_id=13) :scheme: https
[  0.221] recv (stream_id=13) :path: /stylesheets/screen.css
[  0.221] recv (stream_id=13) :authority: nghttp2.org
[  0.221] recv (stream_id=13) accept-encoding: gzip, deflate
[  0.222] recv (stream_id=13) user-agent: nghttp2/1.0.1-DEV
[  0.222] recv PUSH_PROMISE frame <length=50, flags=0x04, stream_id=13>
          ; END_HEADERS
          (padlen=0, promised_stream_id=2)
[  0.222] recv (stream_id=13) :status: 200
[  0.222] recv (stream_id=13) date: Thu, 21 May 2015 16:38:14 GMT
[  0.222] recv (stream_id=13) content-type: text/html
[  0.222] recv (stream_id=13) last-modified: Fri, 15 May 2015 15:38:06 GMT
[  0.222] recv (stream_id=13) etag: W/"555612de-19f6"
[  0.222] recv (stream_id=13) link: </stylesheets/screen.css>; rel=preload; as=stylesheet
[  0.222] recv (stream_id=13) content-encoding: gzip
[  0.222] recv (stream_id=13) server: nghttpx nghttp2/1.0.1-DEV
[  0.222] recv (stream_id=13) via: 1.1 nghttpx
[  0.222] recv (stream_id=13) strict-transport-security: max-age=31536000
[  0.222] recv HEADERS frame <length=166, flags=0x04, stream_id=13>
          ; END_HEADERS
          (padlen=0)
          ; First response header
[  0.222] recv DATA frame <length=2601, flags=0x01, stream_id=13>
          ; END_STREAM
[  0.222] recv (stream_id=2) :status: 200
[  0.222] recv (stream_id=2) date: Thu, 21 May 2015 16:38:14 GMT
[  0.222] recv (stream_id=2) content-type: text/css
[  0.222] recv (stream_id=2) last-modified: Fri, 15 May 2015 15:38:06 GMT
[  0.222] recv (stream_id=2) etag: W/"555612de-9845"
[  0.222] recv (stream_id=2) content-encoding: gzip
[  0.222] recv (stream_id=2) server: nghttpx nghttp2/1.0.1-DEV
[  0.222] recv (stream_id=2) via: 1.1 nghttpx
[  0.222] recv (stream_id=2) strict-transport-security: max-age=31536000
[  0.222] recv HEADERS frame <length=32, flags=0x04, stream_id=2>
          ; END_HEADERS
          (padlen=0)
          ; First push response header
[  0.228] recv DATA frame <length=8715, flags=0x01, stream_id=2>
          ; END_STREAM
[  0.228] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
          (last_stream_id=2, error_code=NO_ERROR(0x00), opaque_data(0)=[])

The HTTP Upgrade is performed like so:

$ nghttp -nvu http://nghttp2.org
[  0.011] Connected
[  0.011] HTTP Upgrade request
GET / HTTP/1.1
Host: nghttp2.org
Connection: Upgrade, HTTP2-Settings
Upgrade: h2c
HTTP2-Settings: AAMAAABkAAQAAP__
Accept: */*
User-Agent: nghttp2/1.0.1-DEV


[  0.018] HTTP Upgrade response
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Upgrade: h2c


[  0.018] HTTP Upgrade success
[  0.018] recv SETTINGS frame <length=12, flags=0x00, stream_id=0>
          (niv=2)
          [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
          [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.018] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
          (niv=2)
          [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
          [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.018] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
          ; ACK
          (niv=0)
[  0.018] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
          (dep_stream_id=0, weight=201, exclusive=0)
[  0.018] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
          (dep_stream_id=0, weight=101, exclusive=0)
[  0.018] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
          (dep_stream_id=0, weight=1, exclusive=0)
[  0.018] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
          (dep_stream_id=7, weight=1, exclusive=0)
[  0.018] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
          (dep_stream_id=3, weight=1, exclusive=0)
[  0.018] send PRIORITY frame <length=5, flags=0x00, stream_id=1>
          (dep_stream_id=11, weight=16, exclusive=0)
[  0.019] recv (stream_id=1) :method: GET
[  0.019] recv (stream_id=1) :scheme: http
[  0.019] recv (stream_id=1) :path: /stylesheets/screen.css
[  0.019] recv (stream_id=1) host: nghttp2.org
[  0.019] recv (stream_id=1) user-agent: nghttp2/1.0.1-DEV
[  0.019] recv PUSH_PROMISE frame <length=49, flags=0x04, stream_id=1>
          ; END_HEADERS
          (padlen=0, promised_stream_id=2)
[  0.019] recv (stream_id=1) :status: 200
[  0.019] recv (stream_id=1) date: Thu, 21 May 2015 16:39:16 GMT
[  0.019] recv (stream_id=1) content-type: text/html
[  0.019] recv (stream_id=1) content-length: 6646
[  0.019] recv (stream_id=1) last-modified: Fri, 15 May 2015 15:38:06 GMT
[  0.019] recv (stream_id=1) etag: "555612de-19f6"
[  0.019] recv (stream_id=1) link: </stylesheets/screen.css>; rel=preload; as=stylesheet
[  0.019] recv (stream_id=1) accept-ranges: bytes
[  0.019] recv (stream_id=1) server: nghttpx nghttp2/1.0.1-DEV
[  0.019] recv (stream_id=1) via: 1.1 nghttpx
[  0.019] recv HEADERS frame <length=157, flags=0x04, stream_id=1>
          ; END_HEADERS
          (padlen=0)
          ; First response header
[  0.019] recv DATA frame <length=6646, flags=0x01, stream_id=1>
          ; END_STREAM
[  0.019] recv (stream_id=2) :status: 200
[  0.019] recv (stream_id=2) date: Thu, 21 May 2015 16:39:16 GMT
[  0.019] recv (stream_id=2) content-type: text/css
[  0.019] recv (stream_id=2) content-length: 38981
[  0.019] recv (stream_id=2) last-modified: Fri, 15 May 2015 15:38:06 GMT
[  0.019] recv (stream_id=2) etag: "555612de-9845"
[  0.019] recv (stream_id=2) accept-ranges: bytes
[  0.019] recv (stream_id=2) server: nghttpx nghttp2/1.0.1-DEV
[  0.019] recv (stream_id=2) via: 1.1 nghttpx
[  0.019] recv HEADERS frame <length=36, flags=0x04, stream_id=2>
          ; END_HEADERS
          (padlen=0)
          ; First push response header
[  0.026] recv DATA frame <length=16384, flags=0x00, stream_id=2>
[  0.027] recv DATA frame <length=7952, flags=0x00, stream_id=2>
[  0.027] send WINDOW_UPDATE frame <length=4, flags=0x00, stream_id=0>
          (window_size_increment=33343)
[  0.032] send WINDOW_UPDATE frame <length=4, flags=0x00, stream_id=2>
          (window_size_increment=33707)
[  0.032] recv DATA frame <length=14645, flags=0x01, stream_id=2>
          ; END_STREAM
[  0.032] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
          ; ACK
          (niv=0)
[  0.032] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
          (last_stream_id=2, error_code=NO_ERROR(0x00), opaque_data(0)=[])

Using the -s option, nghttp prints out some timing information for requests, sorted by completion time:

$ nghttp -nas https://nghttp2.org/
***** Statistics *****

Request timing:
  responseEnd: the  time  when  last  byte of  response  was  received
               relative to connectEnd
 requestStart: the time  just before  first byte  of request  was sent
               relative  to connectEnd.   If  '*' is  shown, this  was
               pushed by server.
      process: responseEnd - requestStart
         code: HTTP status code
         size: number  of  bytes  received as  response  body  without
               inflation.
          URI: request URI

see http://www.w3.org/TR/resource-timing/#processing-model

sorted by 'complete'

id  responseEnd requestStart  process code size request path
 13    +37.19ms       +280us  36.91ms  200   2K /
  2    +72.65ms *   +36.38ms  36.26ms  200   8K /stylesheets/screen.css
 17    +77.43ms     +38.67ms  38.75ms  200   3K /javascripts/octopress.js
 15    +78.12ms     +38.66ms  39.46ms  200   3K /javascripts/modernizr-2.0.js

Using the -r option, nghttp writes more detailed timing data to the given file in HAR format.

nghttpd - server

nghttpd is a multi-threaded static web server.

By default, it uses SSL/TLS connection. Use --no-tls option to disable it.

nghttpd only accepts HTTP/2 connections via ALPN or direct HTTP/2 connections. No HTTP Upgrade is supported.

The -p option allows users to configure server push.

Just like nghttp, it has a verbose output mode for framing information. Here is sample output from nghttpd:

$ nghttpd --no-tls -v 8080
IPv4: listen 0.0.0.0:8080
IPv6: listen :::8080
[id=1] [  1.521] send SETTINGS frame <length=6, flags=0x00, stream_id=0>
          (niv=1)
          [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
[id=1] [  1.521] recv SETTINGS frame <length=12, flags=0x00, stream_id=0>
          (niv=2)
          [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
          [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[id=1] [  1.521] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
          ; ACK
          (niv=0)
[id=1] [  1.521] recv PRIORITY frame <length=5, flags=0x00, stream_id=3>
          (dep_stream_id=0, weight=201, exclusive=0)
[id=1] [  1.521] recv PRIORITY frame <length=5, flags=0x00, stream_id=5>
          (dep_stream_id=0, weight=101, exclusive=0)
[id=1] [  1.521] recv PRIORITY frame <length=5, flags=0x00, stream_id=7>
          (dep_stream_id=0, weight=1, exclusive=0)
[id=1] [  1.521] recv PRIORITY frame <length=5, flags=0x00, stream_id=9>
          (dep_stream_id=7, weight=1, exclusive=0)
[id=1] [  1.521] recv PRIORITY frame <length=5, flags=0x00, stream_id=11>
          (dep_stream_id=3, weight=1, exclusive=0)
[id=1] [  1.521] recv (stream_id=13) :method: GET
[id=1] [  1.521] recv (stream_id=13) :path: /
[id=1] [  1.521] recv (stream_id=13) :scheme: http
[id=1] [  1.521] recv (stream_id=13) :authority: localhost:8080
[id=1] [  1.521] recv (stream_id=13) accept: */*
[id=1] [  1.521] recv (stream_id=13) accept-encoding: gzip, deflate
[id=1] [  1.521] recv (stream_id=13) user-agent: nghttp2/1.0.0-DEV
[id=1] [  1.521] recv HEADERS frame <length=41, flags=0x25, stream_id=13>
          ; END_STREAM | END_HEADERS | PRIORITY
          (padlen=0, dep_stream_id=11, weight=16, exclusive=0)
          ; Open new stream
[id=1] [  1.521] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
          ; ACK
          (niv=0)
[id=1] [  1.521] send HEADERS frame <length=86, flags=0x04, stream_id=13>
          ; END_HEADERS
          (padlen=0)
          ; First response header
          :status: 200
          server: nghttpd nghttp2/1.0.0-DEV
          content-length: 10
          cache-control: max-age=3600
          date: Fri, 15 May 2015 14:49:04 GMT
          last-modified: Tue, 30 Sep 2014 12:40:52 GMT
[id=1] [  1.522] send DATA frame <length=10, flags=0x01, stream_id=13>
          ; END_STREAM
[id=1] [  1.522] stream_id=13 closed
[id=1] [  1.522] recv GOAWAY frame <length=8, flags=0x00, stream_id=0>
          (last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])
[id=1] [  1.522] closed

nghttpx - proxy

nghttpx is a multi-threaded reverse proxy for HTTP/3, HTTP/2, and HTTP/1.1, and powers http://nghttp2.org and supports HTTP/2 server push.

We reworked nghttpx command-line interface, and as a result, there are several incompatibles from 1.8.0 or earlier. This is necessary to extend its capability, and secure the further feature enhancements in the future release. Please read Migration from nghttpx v1.8.0 or earlier to know how to migrate from earlier releases.

nghttpx implements important performance-oriented features in TLS, such as session IDs, session tickets (with automatic key rotation), OCSP stapling, dynamic record sizing, ALPN, forward secrecy and HTTP/2. nghttpx also offers the functionality to share session cache and ticket keys among multiple nghttpx instances via memcached.

nghttpx has 2 operation modes:

Mode option Frontend Backend Note
default mode HTTP/3, HTTP/2, HTTP/1.1 HTTP/1.1, HTTP/2 Reverse proxy
--http2-proxy HTTP/3, HTTP/2, HTTP/1.1 HTTP/1.1, HTTP/2 Forward proxy

The interesting mode at the moment is the default mode. It works like a reverse proxy and listens for HTTP/3, HTTP/2, and HTTP/1.1 and can be deployed as a SSL/TLS terminator for existing web server.

In all modes, the frontend connections are encrypted by SSL/TLS by default. To disable encryption, use the no-tls keyword in --frontend option. If encryption is disabled, incoming HTTP/1.1 connections can be upgraded to HTTP/2 through HTTP Upgrade. On the other hard, backend connections are not encrypted by default. To encrypt backend connections, use tls keyword in --backend option.

nghttpx supports a configuration file. See the --conf option and sample configuration file nghttpx.conf.sample.

In the default mode, nghttpx works as reverse proxy to the backend server:

Client <-- (HTTP/3, HTTP/2, HTTP/1.1) --> nghttpx <-- (HTTP/1.1, HTTP/2) --> Web Server
                                        [reverse proxy]

With the --http2-proxy option, it works as forward proxy, and it is so called secure HTTP/2 proxy:

Client <-- (HTTP/3, HTTP/2, HTTP/1.1) --> nghttpx <-- (HTTP/1.1) --> Proxy
                                         [secure proxy]          (e.g., Squid, ATS)

The Client in the above example needs to be configured to use nghttpx as secure proxy.

At the time of this writing, both Chrome and Firefox support secure HTTP/2 proxy. One way to configure Chrome to use a secure proxy is to create a proxy.pac script like this:

function FindProxyForURL(url, host) {
    return "HTTPS SERVERADDR:PORT";
}

SERVERADDR and PORT is the hostname/address and port of the machine nghttpx is running on. Please note that Chrome requires a valid certificate for secure proxy.

Then run Chrome with the following arguments:

$ google-chrome --proxy-pac-url=file:///path/to/proxy.pac --use-npn

The backend HTTP/2 connections can be tunneled through an HTTP proxy. The proxy is specified using --backend-http-proxy-uri. The following figure illustrates how nghttpx talks to the outside HTTP/2 proxy through an HTTP proxy:

Client <-- (HTTP/3, HTTP/2, HTTP/1.1) --> nghttpx <-- (HTTP/2) --

        --===================---> HTTP/2 Proxy
          (HTTP proxy tunnel)     (e.g., nghttpx -s)

Benchmarking tool

The h2load program is a benchmarking tool for HTTP/3, HTTP/2, and HTTP/1.1. The UI of h2load is heavily inspired by weighttp (https://github.com/lighttpd/weighttp). The typical usage is as follows:

$ h2load -n100000 -c100 -m100 https://localhost:8443/
starting benchmark...
spawning thread #0: 100 concurrent clients, 100000 total requests
Protocol: TLSv1.2
Cipher: ECDHE-RSA-AES128-GCM-SHA256
Server Temp Key: ECDH P-256 256 bits
progress: 10% done
progress: 20% done
progress: 30% done
progress: 40% done
progress: 50% done
progress: 60% done
progress: 70% done
progress: 80% done
progress: 90% done
progress: 100% done

finished in 771.26ms, 129658 req/s, 4.71MB/s
requests: 100000 total, 100000 started, 100000 done, 100000 succeeded, 0 failed, 0 errored
status codes: 100000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 3812300 bytes total, 1009900 bytes headers, 1000000 bytes data
                     min         max         mean         sd        +/- sd
time for request:    25.12ms    124.55ms     51.07ms     15.36ms    84.87%
time for connect:   208.94ms    254.67ms    241.38ms      7.95ms    63.00%
time to 1st byte:   209.11ms    254.80ms    241.51ms      7.94ms    63.00%

The above example issued total 100,000 requests, using 100 concurrent clients (in other words, 100 HTTP/2 sessions), and a maximum of 100 streams per client. With the -t option, h2load will use multiple native threads to avoid saturating a single core on client side.

Warning

Don't use this tool against publicly available servers. That is considered a DOS attack. Please only use it against your private servers.

If the experimental HTTP/3 is enabled, h2load can send requests to HTTP/3 server. To do this, specify h3 to --alpn-list option like so:

$ h2load --alpn-list h3 https://127.0.0.1:4433

For nghttp2 v1.58 or earlier, use --npn-list instead of --alpn-list.

HPACK tools

The src directory contains the HPACK tools. The deflatehd program is a command-line header compression tool. The inflatehd program is a command-line header decompression tool. Both tools read input from stdin and write output to stdout. Errors are written to stderr. They take JSON as input and output. We (mostly) use the same JSON data format described at https://github.com/http2jp/hpack-test-case.

deflatehd - header compressor

The deflatehd program reads JSON data or HTTP/1-style header fields from stdin and outputs compressed header block in JSON.

For the JSON input, the root JSON object must include a cases key. Its value has to include the sequence of input header set. They share the same compression context and are processed in the order they appear. Each item in the sequence is a JSON object and it must include a headers key. Its value is an array of JSON objects, which includes exactly one name/value pair.

Example:

{
  "cases":
  [
    {
      "headers": [
        { ":method": "GET" },
        { ":path": "/" }
      ]
    },
    {
      "headers": [
        { ":method": "POST" },
        { ":path": "/" }
      ]
    }
  ]
}

With the -t option, the program can accept more familiar HTTP/1 style header field blocks. Each header set is delimited by an empty line:

Example:

:method: GET
:scheme: https
:path: /

:method: POST
user-agent: nghttp2

The output is in JSON object. It should include a cases key and its value is an array of JSON objects, which has at least the following keys:

seq
The index of header set in the input.
input_length
The sum of the length of the name/value pairs in the input.
output_length
The length of the compressed header block.
percentage_of_original_size
output_length / input_length * 100
wire
The compressed header block as a hex string.
headers
The input header set.
header_table_size
The header table size adjusted before deflating the header set.

Examples:

{
  "cases":
  [
    {
      "seq": 0,
      "input_length": 66,
      "output_length": 20,
      "percentage_of_original_size": 30.303030303030305,
      "wire": "01881f3468e5891afcbf83868a3d856659c62e3f",
      "headers": [
        {
          ":authority": "example.org"
        },
        {
          ":method": "GET"
        },
        {
          ":path": "/"
        },
        {
          ":scheme": "https"
        },
        {
          "user-agent": "nghttp2"
        }
      ],
      "header_table_size": 4096
    }
    ,
    {
      "seq": 1,
      "input_length": 74,
      "output_length": 10,
      "percentage_of_original_size": 13.513513513513514,
      "wire": "88448504252dd5918485",
      "headers": [
        {
          ":authority": "example.org"
        },
        {
          ":method": "POST"
        },
        {
          ":path": "/account"
        },
        {
          ":scheme": "https"
        },
        {
          "user-agent": "nghttp2"
        }
      ],
      "header_table_size": 4096
    }
  ]
}

The output can be used as the input for inflatehd and deflatehd.

With the -d option, the extra header_table key is added and its associated value includes the state of dynamic header table after the corresponding header set was processed. The value includes at least the following keys:

entries
The entry in the header table. If referenced is true, it is in the reference set. The size includes the overhead (32 bytes). The index corresponds to the index of header table. The name is the header field name and the value is the header field value.
size
The sum of the spaces entries occupied, this includes the entry overhead.
max_size
The maximum header table size.
deflate_size
The sum of the spaces entries occupied within max_deflate_size.
max_deflate_size
The maximum header table size the encoder uses. This can be smaller than max_size. In this case, the encoder only uses up to first max_deflate_size buffer. Since the header table size is still max_size, the encoder has to keep track of entries outside the max_deflate_size but inside the max_size and make sure that they are no longer referenced.

Example:

{
  "cases":
  [
    {
      "seq": 0,
      "input_length": 66,
      "output_length": 20,
      "percentage_of_original_size": 30.303030303030305,
      "wire": "01881f3468e5891afcbf83868a3d856659c62e3f",
      "headers": [
        {
          ":authority": "example.org"
        },
        {
          ":method": "GET"
        },
        {
          ":path": "/"
        },
        {
          ":scheme": "https"
        },
        {
          "user-agent": "nghttp2"
        }
      ],
      "header_table_size": 4096,
      "header_table": {
        "entries": [
          {
            "index": 1,
            "name": "user-agent",
            "value": "nghttp2",
            "referenced": true,
            "size": 49
          },
          {
            "index": 2,
            "name": ":scheme",
            "value": "https",
            "referenced": true,
            "size": 44
          },
          {
            "index": 3,
            "name": ":path",
            "value": "/",
            "referenced": true,
            "size": 38
          },
          {
            "index": 4,
            "name": ":method",
            "value": "GET",
            "referenced": true,
            "size": 42
          },
          {
            "index": 5,
            "name": ":authority",
            "value": "example.org",
            "referenced": true,
            "size": 53
          }
        ],
        "size": 226,
        "max_size": 4096,
        "deflate_size": 226,
        "max_deflate_size": 4096
      }
    }
    ,
    {
      "seq": 1,
      "input_length": 74,
      "output_length": 10,
      "percentage_of_original_size": 13.513513513513514,
      "wire": "88448504252dd5918485",
      "headers": [
        {
          ":authority": "example.org"
        },
        {
          ":method": "POST"
        },
        {
          ":path": "/account"
        },
        {
          ":scheme": "https"
        },
        {
          "user-agent": "nghttp2"
        }
      ],
      "header_table_size": 4096,
      "header_table": {
        "entries": [
          {
            "index": 1,
            "name": ":method",
            "value": "POST",
            "referenced": true,
            "size": 43
          },
          {
            "index": 2,
            "name": "user-agent",
            "value": "nghttp2",
            "referenced": true,
            "size": 49
          },
          {
            "index": 3,
            "name": ":scheme",
            "value": "https",
            "referenced": true,
            "size": 44
          },
          {
            "index": 4,
            "name": ":path",
            "value": "/",
            "referenced": false,
            "size": 38
          },
          {
            "index": 5,
            "name": ":method",
            "value": "GET",
            "referenced": false,
            "size": 42
          },
          {
            "index": 6,
            "name": ":authority",
            "value": "example.org",
            "referenced": true,
            "size": 53
          }
        ],
        "size": 269,
        "max_size": 4096,
        "deflate_size": 269,
        "max_deflate_size": 4096
      }
    }
  ]
}

inflatehd - header decompressor

The inflatehd program reads JSON data from stdin and outputs decompressed name/value pairs in JSON.

The root JSON object must include the cases key. Its value has to include the sequence of compressed header blocks. They share the same compression context and are processed in the order they appear. Each item in the sequence is a JSON object and it must have at least a wire key. Its value is a compressed header block as a hex string.

Example:

{
  "cases":
  [
    { "wire": "8285" },
    { "wire": "8583" }
  ]
}

The output is a JSON object. It should include a cases key and its value is an array of JSON objects, which has at least following keys:

seq
The index of the header set in the input.
headers
A JSON array that includes decompressed name/value pairs.
wire
The compressed header block as a hex string.
header_table_size
The header table size adjusted before inflating compressed header block.

Example:

{
  "cases":
  [
    {
      "seq": 0,
      "wire": "01881f3468e5891afcbf83868a3d856659c62e3f",
      "headers": [
        {
          ":authority": "example.org"
        },
        {
          ":method": "GET"
        },
        {
          ":path": "/"
        },
        {
          ":scheme": "https"
        },
        {
          "user-agent": "nghttp2"
        }
      ],
      "header_table_size": 4096
    }
    ,
    {
      "seq": 1,
      "wire": "88448504252dd5918485",
      "headers": [
        {
          ":method": "POST"
        },
        {
          ":path": "/account"
        },
        {
          "user-agent": "nghttp2"
        },
        {
          ":scheme": "https"
        },
        {
          ":authority": "example.org"
        }
      ],
      "header_table_size": 4096
    }
  ]
}

The output can be used as the input for deflatehd and inflatehd.

With the -d option, the extra header_table key is added and its associated value includes the state of the dynamic header table after the corresponding header set was processed. The format is the same as deflatehd.

Contribution

[This text was composed based on 1.2. License section of curl/libcurl project.]

When contributing with code, you agree to put your changes and new code under the same license nghttp2 is already using unless stated and agreed otherwise.

When changing existing source code, do not alter the copyright of the original file(s). The copyright will still be owned by the original creator(s) or those who have been assigned copyright by the original author(s).

By submitting a patch to the nghttp2 project, you (or your employer, as the case may be) agree to assign the copyright of your submission to us. .. the above really needs to be reworded to pass legal muster. We will credit you for your changes as far as possible, to give credit but also to keep a trace back to who made what changes. Please always provide us with your full real name when contributing!

See Contribution Guidelines for more details.

Versioning

In general, we follow Semantic Versioning.

We may release PATCH releases between the regular releases, mainly for severe security bug fixes.

We have no plan to break API compatibility changes involving soname bump, so MAJOR version will stay 1 for the foreseeable future.

License

The MIT License

nghttp2's People

Contributors

alagoutte avatar andersbakken avatar antbryan avatar anthonyalayo avatar bagder avatar bcard avatar clemahieu avatar davidkorczynski avatar dependabot[bot] avatar fangdingjun avatar hrxi avatar jan-e avatar jchampio avatar jonaski avatar kazuho avatar lekensteyn avatar lpardue avatar mindw avatar nshoemaker avatar piotrsikora avatar remoe avatar rgs1 avatar rraptorr avatar skip2 avatar sp1l avatar tatsuhiro-t avatar tavrez avatar thinred avatar vszakats avatar wzyboy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nghttp2's Issues

suggested way to debug this?

Hi

I think I would like some way to get some verbose debug logging or something from nghttp2 that can help me more than just a return code.

In my case I now provide a full struct of callbacks: https://github.com/bagder/curl/blob/master/lib/http2.c#L265

When I subsequently call nghttp2_session_recv() it does a lot of things and I get callbacks used and it looks pretty good but then in the end it returns -902. That's the value called NGHTTP2_ERR_CALLBACK_FAILURE, but I really have a hard time to figure out what callback that did wrong, and what wrong that could've been!

I figure I can step into nghttp2 with my debugger to figure it out now, but it would also be useful if there was some way to get perhaps a text saying more specifically what the problem is.

Suggestions?

nghttp2_version()

Hi,

I find it really awkward to develop through pull-requests, so here's a link to a commit in my forked repo instead.

I would like to see a nghttp2_version() introduced that returns information about the run-time library in place, ie not assume that the build-time define is what is going to be used down the line when the lib is updated later on but the application is not.

Please consider it a first suggestion, I'm certainly willing to adjust if you have other ideas or opinions about what it should do or not do and how.

https://github.com/bagder/nghttp2/commit/3f5d82c88d1ff6dad30b941445e307ad33dd7585

Thanks!

Build problem

I get this error message when building from git:

shrpx_ssl.cc: In function ‘SSL_CTX* shrpx::ssl::create_ssl_context(const char*, const char*)’:
shrpx_ssl.cc:162:60: error: ‘EC_KEY_new_by_curve_name’ was not declared in this scope
   auto ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
                                                            ^
shrpx_ssl.cc:169:19: error: ‘EC_KEY_free’ was not declared in this scope
   EC_KEY_free(ecdh);
                   ^

nghttp client ignores server push

I have an nghttpd server running as follows:

nghttpd -v --push=/push.html=/style.css --color -d /data 443

push.html contains

<link rel="stylesheet" href="style.css" type="text/css">

If I use firefox to request /push.html, style.css is pushed and firefox correctly doesn't request it.

However if I use nghttp as a client with the following command line:

nghttp -v -a -n https://http2.myserver/push.html

it seems that the server push is ignored, and nghttp still sends a request for style.css (output on the client follows):

[  0.066] send HEADERS frame 
          ; END_STREAM | END_HEADERS
          ; Open new stream
          :authority: http2.myserver
          :method: GET
          :path: /push.html
          :scheme: https
          accept: */*
          accept-encoding: gzip, deflate
          user-agent: nghttp2/0.3.0-DEV
...
[  0.079] recv PUSH_PROMISE frame 
          ; END_PUSH_PROMISE
          (promised_stream_id=2)
          :method: GET
          :path: /style.css
          :scheme: https
          :authority: http2.myserver
[  0.079] recv HEADERS frame 
          ; END_HEADERS
          ; First response header
          :status: 200
          server: nghttpd nghttp2/0.3.0-DEV
          content-length: 53086
          cache-control: max-age=3600
          date: Sun, 26 Jan 2014 17:20:55 GMT
          last-modified: Thu, 05 Dec 2013 06:03:06 GMT
[  0.083] recv DATA frame 
...
[  0.085] send HEADERS frame 
          ; END_STREAM | END_HEADERS | PRIORITY
          (pri=1073741825)
          ; Open new stream
          :authority: http2.myserver
          :method: GET
          :path: /style.css
          :scheme: https
          accept: */*
          accept-encoding: gzip, deflate
          user-agent: nghttp2/0.3.0-DEV
[  0.088] recv DATA frame 
...

I'm not sure this is by design or not. I understand that nghttp is a simple client and probably is not expected to behave like a real browser, but I thought I'd report the issue anyway.

state variable in nghttp2_huff_decode & nghttp2_hd_huff_decode_context

Hi,

When i try to build with MSVC (for Windows build for Wireshark project), i have the following message error
nghttp2/nghttp2_hd_huffman.c(196) : warning C4244: '=' : conversion from 'const int16_t' to 'uint8_t', possible loss of data

and state variable is int16 in struct nghttp2_huff_decode and uint8 in nghttp2_hd_huff_decode_context

What the better fix ? change type of variable ? or add a cast ?

nghttp2_session_mem_send tiny doc fix

diff --git a/lib/includes/nghttp2/nghttp2.h b/lib/includes/nghttp2/nghttp2.h
index 56951eb..496ac2d 100644
--- a/lib/includes/nghttp2/nghttp2.h
+++ b/lib/includes/nghttp2/nghttp2.h
@@ -1497,7 +1497,7 @@ int nghttp2_session_send(nghttp2_session *session);
  *
  * Returns the serialized data to send.
  *
- * This function behaves like `nghttp2_session_mem_send()` except that
+ * This function behaves like `nghttp2_session_send()` except that
  * it does not use :member:`nghttp2_session_callbacks.send_callback`
  * to transmit data. Instead, it assigns the pointer to the serialized
  * data to the |*data_ptr| and returns its length. The other callbacks

nghttp2 test server rejects SETTINGS frame.

I'm testing the h2-12 code for hyper against the nghttp2 test server, and I'm hitting a GOAWAY frame that I'm not expecting.

When I open the connection, I begin with the preamble and a SETTINGS frame. If this SETTINGS frame has Enable Push present and set to 1, nghttp2 sends a GOAWAY frame with the error code PROTCOL_ERROR. If it has Enable Push present and set to 0, nghttp2 is fine with it.

The SETTINGS frames look like this:

With Enable Push:    000A0400 00000000 02000000 01050000 0001
Without Enable Push: 000A0400 00000000 02000000 00050000 0001

Which is exactly the same apart from the enabling of Server Push. Is this an expected nghttp2 behaviour, or do you think the problem is with my code?

In the meantime, I'm working around it by simply not sending the setting when I want to set it to 1.

The example doesn't build

cd example && make

Gives a lot of errors. I was reading through the example to get a grip of the API when I found discrepancies, and then I tried building the example and... yeah, it fails completely.

best practice to call "nghttp2_submit_data()" multiple times?

nghttp2_submit_data() returns NGHTTP2_ERR_DATA_EXIST when the previously submitted data has not been fully processed yet. I am wondering what is the right way to call nghttp2_submit_data() again if an application has new data to submit after the previously submitted data has been processed. I have thought the following approaches:

  1. call "nghttp2_submit_data()" in "nghttp2_data_source_read_callback()" when EOF is reached. It is too early since "nghttp2_stream_detach_data()" has not been called yet.
  2. call "nghttp2_submit_data()" in "on_frame_send_callback()" if it is the last frame of the previous submission. Still too early for the same reason above.
  3. call "nghttp2_submit_data()" after "nghttp2_session_mem_send()", then application needs to maintain a stream list to remember which stream is eligible to submit data again.

Please suggest the best practice to use "nghttp2_submit_data()".

Thanks
Chen

Got nghttpx error when running as http2-bridge

nghttpx crash with the error below:

nghttpx: shrpx_http2_downstream_connection.cc:528: virtual int shrpx::Http2DownstreamConnection::resume_read(shrpx::IOCtrlReason, size_t): Assertion `downstream_->get_response_datalen() >= consumed' failed.

nghttp2_session_recv() with a limited buffer size to receive data/headers in

My code has a fixed-size buffer to store received data (or headers) in, so when I call nghttp2_session_recv() I need to be able to fill up that buffer as much as possible but never more than so.

The documentation says nghttp2_session_recv will continue to call the recv_callback until it returns EWOULDBLOCK but it feels wrong to have to do that as it would be a lie.

Any suggestions?

API wise, I could perhaps imagine having the nghttp2_on_data_chunk_recv_callback() return information about how much data it could handle and nghttp2 would use that as a signal to stop the receiving for now.

shrpx args in nghttpx

I'm migrating from shrpx,

This is the command I'm translating from:

/shrpx --spdy-proxy --frontend=0.0.0.0,55554 --backend=0.0.0.0,55555 --spdy-max-concurrent-streams=1000000 -n 2 -L INFO --accesslog --no-via /workspace/certs/server.key /workspace/certs/server.crt

However, I can't seem to find the params for

  • --spdy-max-concurrent-streams
  • -n
  • -L INFO
  • --accesslog
  • --no-via

for nghttp2, are these still there and undocumented, or?

Can't upgrade against nghttpd

Running nghttpd with the following command line:

nghttpd  -v --no-tls --color -d /webroot/ 8080

Trying to do an upgrade with the client:

# nghttp -u -n -v --color http://10.0.0.1:8080
[  0.000] HTTP Upgrade request
GET / HTTP/1.1
Host: 10.0.0.1:8080
Connection: Upgrade, HTTP2-Settings
Upgrade: HTTP-draft-09/2.0
HTTP2-Settings: AAAABAAAAGQAAAAHAAD__w
Accept: */*
User-Agent: nghttp2/0.3.0-DEV


Failed to parse HTTP Upgrade response header: (HPE_INVALID_CONSTANT) invalid constant string
Some requests were not processed. total=1, processed=0

Is this expected? Do I have to run the proxy in between to be able to upgrade?

ToS field

Could you pls forward the incoming ToS field unchanged in nghttpx?
Currently to ToS field is reset to 0x00

Performance degradation, when downloading multiple files

I tried your library, and it works good when issuing requests in sequence. But when I tested it running 20 parallel downloads 200Kb file it was about 3-5 times slower than regular http1.1 proxy. Used default config, there was a chain - Firefox - nghttp2 client proxy - nghttp2 server proxy - nginx. Did you try such performance tests?

How get get window size > 4096 for sending large amounts of data

I would like to be able to send more than 4096 bytes in a single frame. I have set the intial window side on both sides to the max value (I stole your frame logging code):

[1406906541.461] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
(niv=2)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):128]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):2147483647]
[New Thread 0x7ffff6dde700 (LWP 14749)]
[1406906541.465] recv SETTINGS frame <length=24, flags=0x00, stream_id=0>
(niv=4)
[SETTINGS_HEADER_TABLE_SIZE(0x01):4096]
[SETTINGS_ENABLE_PUSH(0x02):1]
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):2147483647]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]

It seems like the nghttp2_session_next_data_read method used to acquire the number bytes to send will never return greater than NGHTTP2_DATA_PAYLOADLEN bytes due to the initialization code and then cascading this value through nghttp2_min calls. I am interpreting this correctly, and if not what am I missing?

Does nghttpx support server push?

I see that nghttpx disables server push in the SETTINGS it sends to the backend.

[id=1] [ 29.629] recv SETTINGS frame 
          (niv=3)
          [SETTINGS_ENABLE_PUSH(2):0]
          [SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
          [SETTINGS_INITIAL_WINDOW_SIZE(7):65535]

Is this by design?

Why clear_request_headers() after *DownstreamConnection::push_request_headers?

Hi, I'm trying to add server push support to nghttpx (via X-Associated-Content header), and need to access downstream headers to copy some of them to the push request. This is done obiviously after the original request has been sent (on receiving response headers), and Downstream::request_headers_ field is already empty. I wonder, what's the reason for doing that? I haven't found any implications about it in the code. Downstreams are not pooled, they are 1-to-1 to request.

new release for h2-13

Could you please cut a new release now that support for h2-13 is in? I'd like to release an updated package for my Gentoo Linux overlay, which needs a new version number.

BTW, I love your work! Thanks

Can't Build the last release of http/2

hello,

I'm having this error when i tried to make the last release of http/2 :

In file included from shrpx_http2_upstream.cc:38:0:
shrpx_worker_config.h:44:1: erreur: ‘thread_local’ does not name a type
shrpx_http2_upstream.cc: In function ‘int shrpx::{anonymous}::on_request_headers(shrpx::Http2Upstream_, shrpx::Downstream_, nghttp2_session_, const nghttp2_frame_)’:
shrpx_http2_upstream.cc:289:13: erreur: ‘worker_config’ was not declared in this scope
shrpx_http2_upstream.cc: In member function ‘virtual int shrpx::Http2Upstream::on_downstream_header_complete(shrpx::Downstream_)’:
shrpx_http2_upstream.cc:1197:13: erreur: ‘worker_config’ was not declared in this scope
make[2]: *_* [shrpx_http2_upstream.o] Erreur 1

Anyone knows why?
Cheers

Upgrade fails if flow control is disabled

With a built from git nghttp:

$ nghttp -u -f -n -a -v --color http://106.186.112.116/
lt-nghttp: nghttp.cc:582: int nghttp2::{anonymous}::HttpClient::on_upgrade_connect(): Assertion `sizeof(settings_payload) >= 8*niv' failed.
Aborted

But enabling flow control it works:

$ nghttp -u -n -a -v --color http://106.186.112.116/
[  0.276] HTTP Upgrade request
GET / HTTP/1.1
Host: 106.186.112.116
Connection: Upgrade, HTTP2-Settings
Upgrade: HTTP-draft-09/2.0
HTTP2-Settings: AAAABAAAAGQAAAAHAAD__w
Accept: */*
User-Agent: nghttp2/0.3.0-DEV


[  0.555] HTTP Upgrade response
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Upgrade: HTTP-draft-09/2.0


[  0.555] HTTP Upgrade success
...

Too large header block size

Current git version has a bug

[INFO] [UPSTREAM:0x80c5820] HTTP request started
(shrpx_https_upstream.cc:75)
[INFO] [UPSTREAM:0x80c5820] Too large header block size=539782771
(shrpx_https_upstream.cc:106)
[INFO] [UPSTREAM:0x80c5820] HTTP parse failure: (HPE_CB_header_field) the on_header_field callback failed
(shrpx_https_upstream.cc:346)

the server cannot answer chromium requests

Hello,

I'm trying to run some tests using the nghttp server. The problem is that when i try to use chromium as a client i'm having this problem :

SSL/TLS handshake completed
The negotiated protocol: http/1.1
Client did not advertise HTTP/2.0 protocol. (nghttp2 expects h2-10)

Chromium implement only draft 06 of http2. But i need to use it as a client because it's the only browser supporting secure proxys.

The architecture that i'm seeking is :
( client(ideally chromium) <------> secure proxy <------> server )

Do you have any idea about how can i do this.
Sincerely,

Base64 vs. Base64Url

Hi,
not sure if it's curl or nghttp2 problem.
The HTTP/2.0 request sent by curl looks like:
HttpRequestPacket (
method=GET
url=/download/1
query=null
protocol=HTTP/1.1
content-length=-1
headers=[
user-agent=curl/7.38.0-DEV
host=localhost:7070
accept=/
connection=Upgrade, HTTP2-Settings
upgrade=h2c-13
http2-settings=AAMAAABkAAQAAP//]
)

as we see the HTTP2-Settings value is "AAMAAABkAAQAAP//", where according to the HTTP/2.0 draft 13:
"The content of the "HTTP2-Settings" header field is the payload of a
SETTINGS frame (Section 6.5), encoded as a base64url string (that is,
the URL- and filename-safe Base64 encoding described in Section 5 of
[RFC4648]"

in section 5 of [RFC4648] there is no slash symbol in the Base64Url table, this symbol only exists in Base64 table, but as I mentioned HTTP/2.0 has to use Base64Url.

Thank you!

where do I hold discussions / send questions on nghttp2?

Hi Tatsuhiro, I'm slowing starting to research your work here and figure out the API etc and I was wondering if there's a mailing list or something that's suitable if I have questions or feedback or whatever on the design etc ?

Proxy only binds to IPv6 or IPv4, not both

It looks like the proxy -- nghttpx -- only binds to either the IPv4 address or the IPv6 address but not both -- like the server does.

This shows the 1st request over v4. Ignore the 502 bad gateway, the connection to the proxy is at least made:

 curl -v -k -4 https://cdntest.org:8443/
* Adding handle: conn: 0x7fc21100c400
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fc21100c400) send_pipe: 1, recv_pipe: 0
* About to connect() to cdntest.org port 8443 (#0)
*    Trying 93.93.131.187...
* Connected to cdntest.org (93.93.131.187) port 8443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
* Server certificate: Internet Widgits Pty Ltd
> GET / HTTP/1.1
> User-Agent: curl/7.30.0
> Host: cdntest.org:8443
> Accept: */*
>
< HTTP/1.1 502 Bad Gateway
* Server nghttpx nghttp2/0.5.0-DEV is not blacklisted
< Server: nghttpx nghttp2/0.5.0-DEV
< Content-Length: 154
< Content-Type: text/html; charset=UTF-8
<
* Connection #0 to host cdntest.org left intact

and then the same request but made over IPv6 confirms the port isn't open:

curl -v -k -6 https://cdntest.org:8443/
* Adding handle: conn: 0x7f9f4c80c400
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f9f4c80c400) send_pipe: 1, recv_pipe: 0
* About to connect() to cdntest.org port 8443 (#0)
*   Trying 2a00:1098::86:1000:30:0:1...
* Failed connect to cdntest.org:8443; Connection refused
* Closing connection 0
curl: (7) Failed connect to cdntest.org:8443; Connection refused

netstat -tuplanet confirms: https://gist.github.com/xxdesmus/cdc2b06f05c8437a4c90 the proxy isn't bound to v6, only v4.

In my conf file for the proxy I have:

frontend=0.0.0.0,8443
backend=0.0.0.0,8080

You'll notice that the server -- nghttpd -- is properly binding to both IPv4 and IPv6 addresses on the box, but it seems the proxy isn't.

ifconfig shows:

   eth0      Link encap:Ethernet  HWaddr 52:54:00:0c:61:f0
      inet addr:93.93.131.187  Bcast:93.93.131.255  Mask:255.255.255.0
      inet6 addr: 2a00:1098:0:86:1000:30:0:1/64 Scope:Global
      inet6 addr: fe80::5054:ff:fe0c:61f0/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:7360093 errors:0 dropped:5 overruns:0 frame:0
      TX packets:126380 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:617483311 (617.4 MB)  TX bytes:27966076 (27.9 MB)

Any ideas?

Hide nghttp2_session_callbacks struct details

Currently we expose nghttp2_session_callbacks struct to public.
But this is not good because each time we add new callbacks, we need so name bump, breaking binary compatibility.
So I decided to hide the details of the struct and provide functions to set each callback separately.
Work has been mostly done in my local branch so no PR is necessary for this item.

Content encoding using Gzip/ deflate not working

Everything is in the title, Is it an option that should be allowed when configuring the server ?
here is a capture of the logs ( from the server side)

[id=1] [ 50.531] recv SETTINGS frame <length=15, flags=0x00, stream_id=0>
(niv=3)
[SETTINGS_MAX_CONCURRENT_STREAMS(3):100]
[SETTINGS_INITIAL_WINDOW_SIZE(4):65535]
[SETTINGS_COMPRESS_DATA(5):1]
[id=1] [ 50.531](stream_id=1, noind=0) :authority: localhost:8080
[id=1] [ 50.532](stream_id=1, noind=0) :method: GET
[id=1] [ 50.532](stream_id=1, noind=0) :path: /config.h
[id=1] [ 50.532](stream_id=1, noind=0) :scheme: http
[id=1] [ 50.532](stream_id=1, noind=0) accept: /
[id=1] [ 50.532](stream_id=1, noind=0) accept-encoding: gzip, deflate
[id=1] [ 50.532](stream_id=1, noind=0) user-agent: nghttp2/0.5.0-DEV
[id=1] [ 50.532] recv HEADERS frame <length=56, flags=0x05, stream_id=1>
; END_STREAM | END_HEADERS
(padlen=0)
; Open new stream
[id=1] [ 50.532] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[id=1] [ 50.532] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[id=1] [ 50.532] send HEADERS frame <length=83, flags=0x04, stream_id=1>
; END_HEADERS
(padlen=0)
; First response header
:status: 200
cache-control: max-age=3600
content-length: 5894
date: Fri, 23 May 2014 16:07:43 GMT
last-modified: Fri, 23 May 2014 15:05:46 GMT
server: nghttpd nghttp2/0.5.0-DEV

The client advertises that it supports GZIP or deflate as a content encoding protocol, but the server doesn't accept none of them.

I'm using the nghttpd server and nghttp client

Sincerely

http://nghttp2.org/documentation link broken.

Looks like after the upgrade to h2-14 the documentation link does not work. I had observed this issue during last upgrade (from h2-12 to h2-13 as well).

Site admin please restore it so documentation can be accessed.

Thanks
RP

HTTP2 draft 13 per frame compression

I would like to get your thoughts on the removal of per data frame compression support in draft 13. My use case ("internal" mutually authenticated TLS session) would greatly benefit from per frame compression. Do you have any recommendations on how to achieve the per frame compression with after its removal from the specification?

The compression + encryption vulnerabilities I have seen (CRIME, BREACH) seem to rely upon the attacker being able to supply data and get the data back, and in my use case the users are all "internal" and "trusted" via mutual TLS authentication. Am I missing something in terms of compression introducing a larger attack surface in this case?

compile error for nghttp2 v0.4.1 on RHEL/g++ 4.4.7

I am observing following compile errors while building nghttp2 v0.4.1 on RHEL6.5 host.

Tried setting configure with CXXFLAGS = -std=c++0x but didn't help.

CXX util.o
util.cc: In function ‘std::string nghttp2::util::http_date(time_t)’:
util.cc:147: error: ‘nullptr’ was not declared in this scope
util.cc: In function ‘void nghttp2::util::to_token68(std::string&)’:
util.cc:293: error: ‘begin’ is not a member of ‘std’
util.cc:293: error: unable to deduce ‘auto’ from ‘’
util.cc:293: error: ‘end’ is not a member of ‘std’
util.cc:302: error: ‘end’ is not a member of ‘std’
util.cc: In function ‘void nghttp2::util::to_base64(std::string&)’:
util.cc:311: error: ‘begin’ is not a member of ‘std’
util.cc:311: error: unable to deduce ‘auto’ from ‘’
util.cc:311: error: ‘end’ is not a member of ‘std’
util.cc: In function ‘void nghttp2::util::inp_strlower(std::string&)’:
util.cc:329: error: ‘begin’ is not a member of ‘std’
util.cc:329: error: unable to deduce ‘auto’ from ‘’
util.cc:329: error: ‘end’ is not a member of ‘std’
util.cc: In function ‘int nghttp2::util::::levenshtein(const char_, const char_, int, int, int, int)’:
util.cc:366: error: ‘begin’ is not a member of ‘std’
util.cc:366: error: ‘begin’ is not a member of ‘std’
util.cc:366: error: ‘end’ is not a member of ‘std’
util.cc: In function ‘void nghttp2::util::show_candidates(const char_, option_)’:
util.cc:381: error: ‘nullptr’ was not declared in this scope
util.cc:408: error: ‘begin’ is not a member of ‘std’
util.cc:408: error: ‘end’ is not a member of ‘std’
util.cc:415: error: expected initializer before ‘:’ token
util.cc:590: error: expected primary-expression at end of input
util.cc:590: error: expected ‘;’ at end of input
util.cc:590: error: expected primary-expression at end of input
util.cc:590: error: expected ‘)’ at end of input
util.cc:590: error: expected statement at end of input
util.cc:590: error: expected ‘}’ at end of input
util.cc: At global scope:
util.cc:590: error: expected ‘}’ at end of input
util.cc:590: error: expected ‘}’ at end of input

docs online and missing tutorial

Hello,

Any chance you can host the latest docs somewhere online so that it gets easier to browse it from multiple locations?

Since the example isn't adapted yet, I think it would be a good idea to get some basic tutorial like documentation that explains the big picture of how this lib is supposed to be used.

nghttp2_pack_settings_payload

The documentation for nghttp2_pack_settings_payload currently says "The buf must have enough region to hold serialized data" without specifying how large that is. I think either the documentation should state what a "large enough" buffer means, or it should get an additional argument where we tell the function how large the buffer is - and then nghttp2 can return an error if too small. (I personally would prefer getting both.) Otherwise we are destined to get an overflow there sooner or later...

Allow early access to nghttp2_frame_hd

Is it possible to add a new callback API "nghttp2_on_begin_frame_callback" to "nghttp2_session_callbacks", which is called whenever a frame header is received?

This allows users to access the frame header as soon as it becomes available and be able to

  1. learn the frame length and pre-allocate a data buffer in a single memory allocation to receive data chunks received in nghttp2_on_data_chunk_recv_callback.
  2. learn the frame type and flags before receiving payload, which may be useful in HTTP/2 extension.

Basically, this API is an extension of "nghttp2_on_begin_headers_callback" to allow users to access frame headers for every frames instead of just header frames.

Thanks
Chen

Thanks - and compatibility update

@tatsuhiro-t - No issue, I just wanted to say thanks for all your efforts! The API is well thought out and your examples are very helpful to demonstrate the use cases!

I am building an HTTP/2 server based upon your v0.4.1 and interacting with a netty (which has draft 12 support) based client. I am happy to report they are communicating and compatible for my use case. kudos!

[ERROR] Certificate verification failed: self signed certificate

Hello,

I'm trying to build this architecture :
client <----> proxy <----> server.

I'm using google Chroome as a client , proxy ( nghttpx proxy) and server (nghttpd)
When i run the test, the proxy is showing this error :
[ERROR] Certificate verification failed: self signed certificate
(shrpx_ssl.cc:503)

I thought it was a chromium issue, so i imported the certificate to chromium certificate autorities but it didn't solve the issue.

then, I saw that to avoid this error i can become a Certification Authority and add cacert option to nghttp.conf.sample file, but it didn't work.

To become a CA i followed those instructions :
https://help.ubuntu.com/12.04/serverguide/certificates-and-security.html

Anyone can help ?
cheers

Failing build

Trying to build from master, getting:

In file included from app_helper.cc:46:0:
app_helper.h:92:1: error: ‘steady_clock’ in namespace ‘std::chrono’ does not name a type
app_helper.cc:441:1: error: ‘steady_clock’ in namespace ‘std::chrono’ does not name a type
app_helper.cc: In function ‘void nghttp2::reset_timer()’:
app_helper.cc:446:3: error: ‘base_tv’ was not declared in this scope
app_helper.cc:446:26: error: ‘std::chrono::steady_clock’ has not been declared
app_helper.cc: In function ‘std::chrono::milliseconds nghttp2::get_timer()’:
app_helper.cc:451:34: error: ‘std::chrono::steady_clock’ has not been declared
app_helper.cc:451:55: error: ‘base_tv’ was not declared in this scope
app_helper.cc: At global scope:
app_helper.cc:454:1: error: ‘steady_clock’ in namespace ‘std::chrono’ does not name a type
app_helper.cc: In function ‘std::chrono::milliseconds nghttp2::get_timer()’:
app_helper.cc:452:1: warning: control reaches end of non-void function [-Wreturn-type]
make[2]: *** [app_helper.o] Error 1

Compile error for nghttp2 0.5.0.

I'm adding support for hyper to optionally use nghttp2 to do HPACK compression using the Python bindings, but I've hit a compile error on Travis CI. The output is here, but I've reproduced the relevant bits below.

Any insight?

    Version:        0.5.0 shared 4:0:0
    Host type:      x86_64-unknown-linux-gnu
    Install prefix: /usr/local
    C compiler:     gcc-4.8
    CFLAGS:         -g -O2
    LDFLAGS:        
    LIBS:           
    CPPFLAGS:       
    C preprocessor: gcc-4.8 -E
    C++ compiler:   g++-4.8
    CXXFLAGS:       -g -O2 -std=c++11
    CXXCPP:         g++-4.8 -E
    Library types:  Shared=yes, Static=yes
    Python:         /home/travis/virtualenv/python2.7.6/bin/python
    PYTHON_VERSION: 2.7
    pyexecdir:      ${exec_prefix}/lib/python2.7/site-packages
    Python-dev:     yes
    PYTHON_CPPFLAGS:-I/opt/python/2.7.6/include/python2.7
    PYTHON_LDFLAGS: -L/opt/python/2.7.6/lib -lpython2.7
    Cython:         cython
    CUnit:          yes
    OpenSSL:        yes
    Libxml2:        yes
    Libevent(SSL):  yes
    Spdylay:        no
    Jansson:        no
    Jemalloc:       yes
    Applications:   yes
    HPACK tools:    no
    Examples:       yes
    Python bindings:yes
    Failmalloc:     no


  CXXLD  nghttpx
shrpx.o: In function `shrpx::(anonymous namespace)::reopen_log_signal_cb(int, short, void*)':
/home/travis/build/Lukasa/hyper/nghttp2-0.5.0/src/shrpx.cc:1451: undefined reference to `_ZTHN5shrpx13worker_configE'
libnghttpx.a(shrpx_http2_upstream.o): In function `shrpx::Http2Upstream::on_downstream_header_complete(shrpx::Downstream*)':
/home/travis/build/Lukasa/hyper/nghttp2-0.5.0/src/shrpx_http2_upstream.cc:1329: undefined reference to `_ZTHN5shrpx13worker_configE'
/home/travis/build/Lukasa/hyper/nghttp2-0.5.0/src/shrpx_http2_upstream.cc:1329: undefined reference to `_ZTHN5shrpx13worker_configE'
libnghttpx.a(shrpx_http2_upstream.o): In function `on_request_headers':
/home/travis/build/Lukasa/hyper/nghttp2-0.5.0/src/shrpx_http2_upstream.cc:1329: undefined reference to `_ZTHN5shrpx13worker_configE'
/home/travis/build/Lukasa/hyper/nghttp2-0.5.0/src/shrpx_http2_upstream.cc:1329: undefined reference to `_ZTHN5shrpx13worker_configE'
libnghttpx.a(shrpx_https_upstream.o):/home/travis/build/Lukasa/hyper/nghttp2-0.5.0/src/shrpx_https_upstream.cc:914: more undefined references to `_ZTHN5shrpx13worker_configE' follow
collect2: error: ld returned 1 exit status
make[2]: *** [nghttpx] Error 1
make[2]: Leaving directory `/home/travis/build/Lukasa/hyper/nghttp2-0.5.0/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/travis/build/Lukasa/hyper/nghttp2-0.5.0'
make: *** [all] Error 2

sphinx_rtd_theme is not in the release

If you download the release tarball for 0.3.0 there is no doc/_themes/sphinx_rtd_theme directory. That means that building the html (make html) always fails.

Fix: add _theme dir and _themes/sphinx_rtd_theme to doc/Makefile.am SUBDIRS and add doc/_themes/Makefile.am with the contents of that dir, update configure.ac to add the new dirs. I can probably work on a patch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.