An HTTP/2 client and server implementation
npm install node-http2node-http2
==========
An HTTP/2 (RFC 7540)
client and server implementation for node.js.

Original Source
--------------------
This version is a fork of node-http2 hosted on Github originally made by
Gábor Molnár and available here: https://github.com/molnarg/node-http2
This fork of node-http2 module start at version 4.0.0 in case previous repository pick-up work on version 3.x.x.
Installation
------------
```
npm install node-http2
API
---
The API is very similar to the standard node.js HTTPS API. The
goal is the perfect API compatibility, with additional HTTP2 related extensions (like server push).
Detailed API documentation is primarily maintained in the lib/http.js file and is available in
the wiki as well.
Examples
--------
`javascript
var options = {
key: fs.readFileSync('./example/localhost.key'),
cert: fs.readFileSync('./example/localhost.crt')
};
require('http2').createServer(options, function(request, response) {
response.end('Hello world!');
}).listen(8080);
`
`javascript`
require('http2').get('https://localhost:8080/', function(response) {
response.pipe(process.stdout);
});
An simple static file server serving up content from its own directory is available in the example
directory. Running the server:
`bash`
$ node ./example/server.js
An example client is also available. Downloading the server's own source code from the server:
`bash`
$ node ./example/client.js 'https://localhost:8080/server.js' >/tmp/server.js
For a server push example, see the source code of the example
server and
client.
Status
------
* ALPN is only supported in node.js >= 5.0
* Upgrade mechanism to start HTTP/2 over unencrypted channel is not implemented yet
(issue #4)
* Other minor features found in
this list are not implemented yet
Development
-----------
There's a few library you will need to have installed to do anything described in the following
sections. After installing/cloning node-http2, run npm install in its directory to install
development dependencies.
Used libraries:
* mocha for tests
* chai for assertions
* istanbul for code coverage analysis
* docco for developer documentation
* bunyan for logging
For pretty printing logs, you will also need a global install of bunyan (npm install -g bunyan).
The developer documentation is generated from the source code using docco and can be viewed online
here. If you'd like to have an offline copy, just run
npm run-script doc.
It's easy, just run npm test. The tests are written in BDD style, so they are a good starting
point to understand the code.
To generate a code coverage report, run npm test --coverage (which runs very slowly, be patient).`
Code coverage summary as of version 3.0.1:`
Statements : 89.44% ( 1947/2177 )
Branches : 79.45% ( 816/1027 )
Functions : 89.06% ( 228/256 )
Lines : 89.53% ( 1941/2168 )
There's a hosted version of the detailed (line-by-line) coverage report
here.
Logging is turned off by default. You can turn it on by passing a bunyan logger as log option when
creating a server or agent.
When using the example server or client, it's very easy to turn logging on: set the HTTP2_LOGfatal
environment variable to , error, warn, info, debug or trace (the logging level).HTTP2_LOG_DATA=1
To log every single incoming and outgoing data chunk, use besidesHTTP2_LOG=trace. Log output goes to the standard error output. If the standard error is redirected
into a file, then the log output is in bunyan's JSON format for easier post-mortem analysis.
Running the example server and client with info level logging output:
`bash`
$ HTTP2_LOG=info node ./example/server.js
`bash``
$ HTTP2_LOG=info node ./example/client.js 'https://localhost:8080/server.js' >/dev/null
Contributors
------------
The co-maintainer of the project is Nick Hurley.
Code contributions are always welcome! People who contributed to node-http2 so far:
* Nick Hurley
* Mike Belshe
* Yoshihiro Iwanaga
* Igor Novikov
* James Willcox
* David Björklund
* Patrick McManus
Special thanks to Google for financing the development of this module as part of their Summer of
Code program (project: HTTP/2 prototype server
implementation), and
Nick Hurley of Mozilla, my GSoC mentor, who helped with regular code review and technical advices.
License
-------
The MIT License
Copyright (C) 2013 Gábor Molnár