h2c
v1.1.1
Published
A basic HTTP/2 CLI client for Node.js.
Downloads
11
Readme
h2c
A basic HTTP/2 command-line client for making web requests with Node.js. HTTP/1.1 and earlier are not supported.
Installation
Install globally to be able to use the h2c
command from anywhere.
$ npm install h2c --global
Usage
Providing an absolute URI as the only argument will submit a GET request.
$ h2c http://localhost:3000/hello
The response headers and response body are then printed to stdout
.
HTTP/2 200 OK
content-type: text/plain; charset=UTF-8
content-length: 13
date: Wed, 03 Jun 2020 07:00:40 GMT
Hello, world!
Options
-m, --method
Set the request method. Defaults to GET.
$ h2c -m HEAD http://localhost:3000/
-h, --header
Set a request header. Can be used multiple times to add multiple headers.
$ h2c -h 'accept: application/json' -h 'accept-language: en-US,en;q=0.5' http://localhost:3000/
d, --data
Add data to the request body. Only applies to POST, PUT, and PATCH requests.
$ h2c -m POST -d '{"foo":42}' -h 'content-type: application/json' http://localhost:3000/