Skip to content

Commit

Permalink
Replace HTTP/2.0 with HTTP/2
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuhiro-t committed Mar 30, 2014
1 parent 705051c commit ab2dc59
Show file tree
Hide file tree
Showing 174 changed files with 263 additions and 263 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# nghttp2 - HTTP/2.0 C Library
# nghttp2 - HTTP/2 C Library

# Copyright (c) 2012 Tatsuhiro Tsujikawa

Expand Down
64 changes: 32 additions & 32 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
nghttp2 - HTTP/2.0 C Library
nghttp2 - HTTP/2 C Library
============================

This is an experimental implementation of Hypertext Transfer Protocol
version 2.0.
version 2.

Development Status
------------------
Expand Down Expand Up @@ -150,12 +150,12 @@ http://tatsuhiro-t.github.io/nghttp2/
Client, Server and Proxy programs
---------------------------------

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

nghttp - client
+++++++++++++++

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

It has verbose output mode for framing information. Here is sample
Expand Down Expand Up @@ -279,8 +279,8 @@ nghttpd - server
By default, it uses SSL/TLS connection. Use ``--no-tls`` option to
disable it.

``nghttpd`` only accepts the HTTP/2.0 connection via NPN/ALPN or direct
HTTP/2.0 connection. No HTTP Upgrade is supported.
``nghttpd`` only accepts the HTTP/2 connection via NPN/ALPN or direct
HTTP/2 connection. No HTTP Upgrade is supported.

``-p`` option allows users to configure server push.

Expand Down Expand Up @@ -338,15 +338,15 @@ nghttpx - proxy
``nghttpx`` is a multi-threaded reverse proxy for
h2-10, SPDY and HTTP/1.1. It has several operation modes:

================== ============================== ============== =============
Mode option Frontend Backend Note
================== ============================== ============== =============
default mode HTTP/2.0, SPDY, HTTP/1.1 (TLS) HTTP/1.1 Reverse proxy
``--http2-proxy`` HTTP/2.0, SPDY, HTTP/1.1 (TLS) HTTP/1.1 SPDY proxy
``--http2-bridge`` HTTP/2.0, SPDY, HTTP/1.1 (TLS) HTTP/2.0 (TLS)
``--client`` HTTP/2.0, HTTP/1.1 HTTP/2.0 (TLS)
``--client-proxy`` HTTP/2.0, HTTP/1.1 HTTP/2.0 (TLS) Forward proxy
================== ============================== ============== =============
================== ============================ ============== =============
Mode option Frontend Backend Note
================== ============================ ============== =============
default mode HTTP/2, SPDY, HTTP/1.1 (TLS) HTTP/1.1 Reverse proxy
``--http2-proxy`` HTTP/2, SPDY, HTTP/1.1 (TLS) HTTP/1.1 SPDY proxy
``--http2-bridge`` HTTP/2, SPDY, HTTP/1.1 (TLS) HTTP/2 (TLS)
``--client`` HTTP/2, HTTP/1.1 HTTP/2 (TLS)
``--client-proxy`` HTTP/2, HTTP/1.1 HTTP/2 (TLS) Forward proxy
================== ============================ ============== =============

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
Expand All @@ -356,7 +356,7 @@ The default mode, ``--http2-proxy`` and ``--http2-bridge`` modes use
SSL/TLS in the frontend connection by default. To disable SSL/TLS, use
``--frontend-no-tls`` 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.
HTTP/2 through HTTP Upgrade.

The ``--http2-bridge``, ``--client`` and ``--client-proxy`` modes use
SSL/TLS in the backend connection by deafult. To disable SSL/TLS, use
Expand All @@ -371,13 +371,13 @@ In the default mode, (without any of ``--http2-proxy``,
``--http2-bridge``, ``--client-proxy`` and ``--client`` options),
``nghttpx`` works as reverse proxy to the backend server::

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

With ``--http2-proxy`` option, it works as so called secure proxy (aka
SPDY proxy)::

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

The ``Client`` in the above is needs to be configured to use
Expand All @@ -401,42 +401,42 @@ Then run Chrome with the following arguments::

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

With ``--http2-bridge``, it accepts HTTP/2.0, SPDY and HTTP/1.1
connections and communicates with backend in HTTP/2.0::
With ``--http2-bridge``, it accepts HTTP/2, SPDY and HTTP/1.1
connections and communicates with backend in HTTP/2::

Client <-- (HTTP/2.0, SPDY, HTTP/1.1) --> nghttpx <-- (HTTP/2.0) --> Web or HTTP/2.0 Proxy etc
Client <-- (HTTP/2, SPDY, HTTP/1.1) --> nghttpx <-- (HTTP/2) --> Web or HTTP/2 Proxy etc
(e.g., nghttpx -s)

With ``--client-proxy`` option, it works as forward proxy and expects
that the backend is HTTP/2.0 proxy::
that the backend is HTTP/2 proxy::

Client <-- (HTTP/2.0, HTTP/1.1) --> nghttpx <-- (HTTP/2.0) --> HTTP/2.0 Proxy
Client <-- (HTTP/2, HTTP/1.1) --> nghttpx <-- (HTTP/2) --> HTTP/2 Proxy
[forward proxy] (e.g., nghttpx -s)

The ``Client`` 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.
HTTP/1.1 client to access and test their HTTP/2 servers.

With ``--client`` option, it works as reverse proxy and expects that
the backend is HTTP/2.0 Web server::
the backend is HTTP/2 Web server::

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

The frontend HTTP/1.1 connection can be upgraded to HTTP/2.0
The frontend HTTP/1.1 connection can be upgraded to HTTP/2
through HTTP Upgrade.

For the operation modes which talk to the backend in HTTP/2.0 over
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 ``--backend-http-proxy-uri``
option. The following figure illustrates the example of
``--http2-bridge`` and ``--backend-http-proxy-uri`` options to talk to
the outside HTTP/2.0 proxy through HTTP proxy::
the outside HTTP/2 proxy through HTTP proxy::

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

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

Benchmarking tool
Expand Down
2 changes: 1 addition & 1 deletion android-config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# nghttp2 - HTTP/2.0 C Library
# nghttp2 - HTTP/2 C Library
#
# Copyright (c) 2013 Tatsuhiro Tsujikawa
#
Expand Down
2 changes: 1 addition & 1 deletion android-make
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# nghttp2 - HTTP/2.0 C Library
# nghttp2 - HTTP/2 C Library
#
# Copyright (c) 2013 Tatsuhiro Tsujikawa
#
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dnl nghttp2 - HTTP/2.0 C Library
dnl nghttp2 - HTTP/2 C Library

dnl Copyright (c) 2012, 2013 Tatsuhiro Tsujikawa

Expand Down
2 changes: 1 addition & 1 deletion doc/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# nghttp2 - HTTP/2.0 C Library
# nghttp2 - HTTP/2 C Library

# Copyright (c) 2012 Tatsuhiro Tsujikawa

Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# nghttp2 - HTTP/2.0 C Library
# nghttp2 - HTTP/2 C Library

# Copyright (c) 2012 Tatsuhiro Tsujikawa

Expand Down
2 changes: 1 addition & 1 deletion doc/mkapiref.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# nghttp2 - HTTP/2.0 C Library
# nghttp2 - HTTP/2 C Library

# Copyright (c) 2012 Tatsuhiro Tsujikawa

Expand Down
4 changes: 2 additions & 2 deletions doc/sources/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
nghttp2 - HTTP/2.0 C Library
nghttp2 - HTTP/2 C Library
============================

This is an experimental implementation of Hypertext Transfer Protocol
version 2.0.
version 2.

The project is hosted at `github.com/tatsuhiro-t/nghttp2 <https://github.com/tatsuhiro-t/nghttp2>`_.

Expand Down
14 changes: 7 additions & 7 deletions doc/sources/tutorial-client.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Tutorial: HTTP/2.0 client
Tutorial: HTTP/2 client
=========================

In this tutorial, we are going to write very primitive HTTP/2.0
In this tutorial, we are going to write very primitive HTTP/2
client. The complete source code, `libevent-client.c`_, is attached at
the end of this page. It also resides in examples directory in the
archive or repository.
Expand All @@ -19,7 +19,7 @@ function ``main()`` and ``run()``, which is not so relevant to nghttp2
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
`nghttp2_select_next_protocol()` function to select the HTTP/2.0
`nghttp2_select_next_protocol()` function to select the HTTP/2
protocol the library supports::

static int select_next_proto_cb(SSL* ssl,
Expand Down Expand Up @@ -52,7 +52,7 @@ The callback is set to the SSL_CTX object using
}

We use ``http2_session_data`` structure to store the data related to
the HTTP/2.0 session::
the HTTP/2 session::

typedef struct {
nghttp2_session *session;
Expand Down Expand Up @@ -176,7 +176,7 @@ The `delete_http2_session_data()` destroys ``session_data`` and frees
its bufferevent, so it closes underlying connection as well. It also
calls `nghttp2_session_del()` to delete nghttp2 session object.

We begin HTTP/2.0 communication by sending client connection header,
We begin HTTP/2 communication by sending client connection header,
which is 24 bytes magic byte sequence
(:macro:`NGHTTP2_CLIENT_CONNECTION_HEADER`) followed by SETTINGS
frame. The transmission of client connection header is done in
Expand Down Expand Up @@ -371,7 +371,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 ``frame->hd.stream_id``. Recall that we
passed ``stream_data`` in the *stream_user_data* parameter of
Expand Down Expand Up @@ -479,6 +479,6 @@ If the stream ID matches the one we initiated, it means that its
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 `nghttp2_session_terminate_session()` 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.
16 changes: 8 additions & 8 deletions doc/sources/tutorial-server.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Tutorial: HTTP/2.0 server
Tutorial: HTTP/2 server
=========================

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, `libevent-server.c`_, is attached at the end of
this page. It also resides in examples directory in the archive or
Expand Down Expand Up @@ -57,7 +57,7 @@ life time::

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 :macro:`NGHTTP2_PROTO_VERSION_ID`. The ``next_proto_cb()`` function
is the server-side NPN callback. In OpenSSL implementation, we just
Expand All @@ -73,7 +73,7 @@ We use ``app_content`` structure to store the application-wide data::
};

We use ``http2_session_data`` structure to store the session-level
(which corresponds to 1 HTTP/2.0 connection) data::
(which corresponds to 1 HTTP/2 connection) data::

typedef struct http2_session_data {
struct http2_stream_data root;
Expand All @@ -94,7 +94,7 @@ data::
int fd;
} http2_stream_data;

1 HTTP/2.0 session can have multiple streams. We manage these
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
``root->next`` in ``http2_session_data``. Initially, ``root->next``
Expand Down Expand Up @@ -226,10 +226,10 @@ it::

We check that the received byte string matches
:macro:`NGHTTP2_CLIENT_CONNECTION_HEADER`. When they match, the
connection state is ready for starting HTTP/2.0 communication. First
connection state is ready for starting HTTP/2 communication. First
we change the callback functions for the bufferevent object. We use
same ``eventcb`` as before. But we specify new ``readcb`` and
``writecb`` function to handle HTTP/2.0 communication. We describe
``writecb`` function to handle HTTP/2 communication. We describe
these 2 functions later.

We initialize nghttp2 session object which is done in
Expand Down Expand Up @@ -435,7 +435,7 @@ of header block in HEADERS or PUSH_PROMISE frame is started::
}

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 ``http2_stream_data`` object to store stream related
data. We associate created ``http2_stream_data`` object to the stream
Expand Down
2 changes: 1 addition & 1 deletion examples/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# nghttp2 - HTTP/2.0 C Library
# nghttp2 - HTTP/2 C Library

# Copyright (c) 2012 Tatsuhiro Tsujikawa

Expand Down
10 changes: 5 additions & 5 deletions examples/client.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* nghttp2 - HTTP/2.0 C Library
* nghttp2 - HTTP/2 C Library
*
* Copyright (c) 2013 Tatsuhiro Tsujikawa
*
Expand Down Expand Up @@ -146,7 +146,7 @@ static size_t GZIP_LEN = sizeof(GZIP) - 1;

/*
* Check response is content-encoding: gzip. We need this because
* HTTP/2.0 client is required to support gzip.
* HTTP/2 client is required to support gzip.
*/
static void check_gzip(struct Request *req, nghttp2_nv *nva, size_t nvlen)
{
Expand Down Expand Up @@ -395,7 +395,7 @@ static void setup_nghttp2_callbacks(nghttp2_session_callbacks *callbacks)

/*
* Callback function for TLS NPN. Since this program only supports
* HTTP/2.0 protocol, if server does not offer HTTP/2.0 the nghttp2
* HTTP/2 protocol, if server does not offer HTTP/2 the nghttp2
* library supports, we terminate program.
*/
static int select_next_proto_cb(SSL* ssl,
Expand All @@ -404,11 +404,11 @@ static int select_next_proto_cb(SSL* ssl,
void *arg)
{
int rv;
/* nghttp2_select_next_protocol() selects HTTP/2.0 protocol the
/* nghttp2_select_next_protocol() selects HTTP/2 protocol the
nghttp2 library supports. */
rv = nghttp2_select_next_protocol(out, outlen, in, inlen);
if(rv <= 0) {
die("Server did not advertise HTTP/2.0 protocol");
die("Server did not advertise HTTP/2 protocol");
}
return SSL_TLSEXT_ERR_OK;
}
Expand Down
6 changes: 3 additions & 3 deletions examples/libevent-client.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* nghttp2 - HTTP/2.0 C Library
* nghttp2 - HTTP/2 C Library
*
* Copyright (c) 2013 Tatsuhiro Tsujikawa
*
Expand Down Expand Up @@ -190,7 +190,7 @@ static ssize_t send_callback(nghttp2_session *session,

/* nghttp2_before_frame_send_callback: Called when nghttp2 library is
about to send a frame. We use this callback to get stream ID of new
stream. Since HEADERS in HTTP/2.0 has several roles, we check that
stream. Since HEADERS in HTTP/2 has several roles, we check that
it is a HTTP request HEADERS. */
static int before_frame_send_callback
(nghttp2_session *session, const nghttp2_frame *frame, void *user_data)
Expand Down Expand Up @@ -308,7 +308,7 @@ static int on_stream_close_callback(nghttp2_session *session,
}

/* NPN TLS extension client callback. We check that server advertised
the HTTP/2.0 protocol the nghttp2 library supports. If not, exit
the HTTP/2 protocol the nghttp2 library supports. If not, exit
the program. */
static int select_next_proto_cb(SSL* ssl,
unsigned char **out, unsigned char *outlen,
Expand Down
Loading

0 comments on commit ab2dc59

Please sign in to comment.