Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
An HTTP/2 server implementation for node.js, developed as a [Google Summer of Code project] (https://google-melange.appspot.com/gsoc/project/google/gsoc2013/molnarg/5001).
npm install http2
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.
var http2 = require('http2');
var options = {
key: fs.readFileSync('./example/localhost.key'),
cert: fs.readFileSync('./example/localhost.crt')
};
http2.createServer(options, function(request, response) {
response.end('Hello world!');
}).listen(8080);
var http2 = require('http2');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
var request = http2.get('https://gabor.molnar.es:8080/');
request.on('response', 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:
$ node ./example/server.js
Listening on localhost:8080, serving up files from ./example
An example client is also available. Downloading the server's own source code from the server:
$ node ./example/client.js 'https://localhost:8080/server.js' 2>/tmp/server.js
For a server push example, see the source code of the example server and client.
I post weekly status updates on my blog. Short version: main missing items are:
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:
For pretty printing logs, you will also need a global install of bunyan (npm install -g bunyan
).
The developer documentation is located in the doc
directory. The docs are usually updated only
before releasing a new version. To regenerate them manually, run npm run-script prepublish
.
There's a hosted version which is located here.
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 0.2.0:
Statements : 85.04% ( 1177/1384 )
Branches : 70.21% ( 370/527 )
Functions : 83.94% ( 162/193 )
Lines : 85.31% ( 1173/1375 )
There's a hosted version of the detailed (line-by-line) coverage report here.
Logging is turned off by default. To turn it on, set the HTTP2_LOG
environment variable to
fatal
, error
, warn
, info
, debug
or trace
(the logging level). Log output is in JSON
format, and can be pretty printed using the bunyan command line tool.
For example, running the test client with debug level logging output:
HTTP2_LOG=debug node ./example/client.js 'http://localhost:8080/server.js' 2>/tmp/server.js | bunyan
Code contributions are always welcome! People who contributed to node-http2 so far:
Special thanks to Google for financing the development of this module as part of their Summer of Code program, and Nick Hurley of Mozilla, my GSoC mentor, who helps with regular code review and technical advices.
The MIT License
Copyright (C) 2013 Gábor Molnár gabor@molnar.es
FAQs
An HTTP/2 client and server implementation
The npm package http2 receives a total of 37,166 weekly downloads. As such, http2 popularity was classified as popular.
We found that http2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.