Socket
Socket
Sign inDemoInstall

http2

Package Overview
Dependencies
0
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    http2

An HTTP/2 server implementation


Version published
Maintainers
1
Created

Changelog

Source

0.1.0 (2013-08-06) ###

  • First release with public API (similar to the standard node HTTPS module)
  • Support for NPN negotiation (no ALPN or Upgrade yet)
  • Stream number limitation is in place
  • Push streams works but not exposed yet in the public API
  • Blog post
  • Tarball

Readme

Source

node-http2

An HTTP/2 server implementation for node.js, developed as a Google Summer of Code project.

Status

I post weekly status updates on my blog. Short version: the first version of the public API is in place. NPN negotiation works (no ALPN or Upgrade mechanism yet). Main missing items will be tracked in the issue tracker.

Installation

Using npm:

npm install 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). Currently, basic operations work, server push is not yet exposed to the public API. See the examples for more info.

Examples

Using as a server:

var http2 = require('http2');

var options = {
  key: fs.readFileSync('./example/localhost.key'),
  cert: fs.readFileSync('./example/localhost.crt')
};

http2.http.createServer(options, function(request, response) {
  response.end('Hello world!');
}).listen(8080);

Using as a client:

var http2 = require('http2');

var request = http2.request({
  method: 'get',
  host: 'gabor.molnar.es',
  port: 8080,
  url: '/',
  rejectUnauthorized: false
});
request.end();

request.on('response', function(response) {
  response.pipe(process.stdout);
});

An example server (serving up static files from its own directory) and client are 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 source code from the server (the downloaded content gets pumped out to the standard error output):

$ node ./example/client.js 'http://localhost:8080/server.js' 2>/tmp/server.js

Development

Development dependencies

There's a few library you will need to have installed to do anything described in the following sections. After installing node-http2, run npm install in its directory to install development dependencies.

Used libraries:

Developer documentation

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.

Running the tests

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.

Test coverage

To generate a code coverage report, run npm test --coverage. Code coverage summary as of version 0.0.6:

Statements   : 91.18% ( 775/850 )
Branches     : 84.69% ( 249/294 )
Functions    : 88.03% ( 103/117 )
Lines        : 91.18% ( 775/850 )

There's a hosted version of the detailed (line-by-line) coverage report here.

Logging

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

Contributors

  • Nick Hurley
  • Mike Belshe

License

The MIT License

Copyright (C) 2013 Gábor Molnár gabor@molnar.es

Keywords

FAQs

Last updated on 06 Aug 2013

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc