Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
An HTTP/2 (RFC 7540) pure JavaScript client and server implementation for node.js.
This NodeJS http2.js
module 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 named http2.js
starts at version 4.0.0
in case previous the repository decides to pick up work again on version 3.x.x
.
We are aware that node 8.4.0 now has experimental http2
support via --expose-http2
, and we will continue to support the full JavaScript implementation of http2.js
at our discretion until HTTP/2 is more fully supported in a broad range of client platforms.
npm install http2.js
The API is very similar to the standard node.js HTTPS API. The goal is 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 options = {
key: fs.readFileSync('./example/localhost.key'),
cert: fs.readFileSync('./example/localhost.crt')
};
require('http2.js').createServer(options, function(request, response) {
response.end('Hello world!');
}).listen(8080);
require('http2.js').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:
$ node ./example/server.js
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' >/tmp/server.js
For a server push example, see the source code of the example server and client.
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 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 4.0.2:
Statements : 89.41% ( 2017/2256 )
Branches : 79.33% ( 852/1074 )
Functions : 89.47% ( 238/266 )
Lines : 89.45% ( 2009/2246 )
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_LOG
environment variable to fatal
, error
, warn
, info
, debug
or trace
(the logging level).
To log every single incoming and outgoing data chunk, use HTTP2_LOG_DATA=1
besides
HTTP2_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:
$ HTTP2_LOG=info node ./example/server.js
$ HTTP2_LOG=info node ./example/client.js 'https://localhost:8080/server.js' >/dev/null
The co-maintainer of the project is Nick Hurley.
Code contributions are always welcome! People who contributed to node-http2
and http2.js
so far:
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.
The MIT License
Copyright (C) 2013 Gábor Molnár gabor@molnar.es
4.0.3 (2018-07-18)
Update http.js to add support on request for retry-after
header on 503|429|302
status code.
[About 503] The server returns an HTTP error 503 when more users than are allowed by the server's request queue limit have sent requests to a single server or when the actions of the client have triggered throttling.
Retry-After If a Retry-After header ([RFC2616]) is present in the response, the client SHOULD<6> retry the request after waiting the number of seconds indicated by the Retry-After header. Any such value represents an estimate of when the server is expected to be able to process the request.
FAQs
An HTTP/2 client and server implementation
The npm package http2.js receives a total of 4 weekly downloads. As such, http2.js popularity was classified as not popular.
We found that http2.js 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.