package
smol package to work with http2 requests
npm install http2-requestGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Super smol HTTP/2 request library :package:. Optimized for JSON APIs.
var request = require('http2-request')
var fs = require('fs')
var opts = {
url: 'https://localhost:8001',
connectOpts: {
ca: fs.readFileSync('~/http2-request/cert.pem')
},
clientOpts: {},
headers: {
':path': '/'
}
}
request(opts, function (err, headers, body) {
if (err) throw err
if (!headers.isOk()) throw new Error(`statusCode is ${
Create a new instance of http2-request. Takes a few options to connect to an
HTTP/2 client and create and HTTP/2 session:
http2-request will create a new URL object to get the origin{ rejectUnauthorized: false } to avoid rejections from the server, otherwise
pass in a cert under the ca flag.Request has a signature of (err, headers, body):
opts.json is false,
otherwise a JSON object.A convenience method to see if the response comes back <=299 for easier error
checking. Returns a boolean.
A convenience method from HTTP/1.1 to read off the status code. You can also do
so by headers[:status].
npm install http2-requestEstimated unpacked size across 17 packages.
593.6 kB
Includes dependencies.
4 direct · 1 outdated
^3.0.0
3.0.4
^1.6.2
2.0.0
^1.0.3
1.0.3
^2.0.4
2.1.1