http2-cli ·
Modern and lightweight command line HTTP/2 client.
Install
npm
$ npm install -g http2-cli
Since version 5.2.0
, a new package runner tool called npx is shipped with npm. With this new tool you can run any node package binary from the command line without installing it globally first. So you can run http2-cli
with the following command line:
$ npx http2-cli --help
Yarn
$ yarn global add http2-cli
Usage
http2 <method> <url> [headers..] Positionals: method HTTP method [required] [choices: "DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH"] url HTTP URL to request [required] headers HTTP headers to send with the request, e.g. Content-Type:application/json Options: --help Show help [boolean] --version Show version number [boolean] --auth Specify the authentication credentials [string] --auth-type Specify the authentication mechanism [choices: "Basic", "Bearer"] [default: "Basic"] --insecure Disable the host SSL/TLS certificate verification [boolean] --verbose Display the HTTP response headers [boolean]
Examples
Here are some command examples with the corresponding output:
GET request with basic authentication
$ http2 get https://nghttp2.org:443/httpbin/basic-auth/test/test --auth test:test
POST request with redirected input
$ http2 post https://nghttp2.org:443/httpbin/post Content-Type:application/json < foo.json
️️Docker
For docker ❤️ you can run http2-cli
with docker. You can use a prebuilt docker image or build your own. For example the following command run the latest prebuilt docker image of http2-cli
:
$ docker run --rm kevinpollet/http2-cli:latest --versionhttp2-cli/1.1.0 linux-x64 node-v12.3.1
With docker, it's also possible to use Unix redirections and pipes! Try the following commands:
$ docker run --rm -i kevinpollet/http2-cli:latest post https://nghttp2.org/httpbin/post < foo.json $ echo -e '{ "hello": "world" }' | docker run --rm -i kevinpollet/http2-cli:latest post https://nghttp2.org/httpbin/post | jq ".json"
Contributing
✨Contributions are welcome ✨
See CONTRIBUTING.md for more information and how to get started.