Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcollina/h2url
experimental http2 client for node and the CLI
https://github.com/mcollina/h2url
Last synced: about 2 months ago
JSON representation
experimental http2 client for node and the CLI
- Host: GitHub
- URL: https://github.com/mcollina/h2url
- Owner: mcollina
- License: mit
- Created: 2017-10-30T11:26:06.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-18T19:52:06.000Z (about 5 years ago)
- Last Synced: 2024-10-06T01:48:12.869Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 46
- Watchers: 5
- Forks: 10
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# h2url
Experimental http2 client for node and the CLI
## Usage as CLI
```
$ npx h2url https://localhost:3001
```or
```
$ npm i -g h2url
$ h2url https://localhost:3001
```### CLI options
```
Usage: h2url [options..] URLOptions:
-X/--method METHOD the http method to use
-D/--data/--body BODY the http body to send
-v/--verbose show the headers
-h show this help
```## Usage as a module
```
$ npm i h2url
``````js
'use strict'require('make-promises-safe')
const h2url = require('h2url')
const url = 'https://localhost:3001'
const getStream = require('get-stream')async function concat () {
const res = await h2url.concat({ url })
console.log(res)
// prints { headers, body }
}concat()
async function streaming () {
const res = await h2url.request({
method: 'POST',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify('something') // string, buffer or readable stream
})console.log(res.headers)
const body = getStream(res.stream)
console.log(body)
}streaming()
```## License
MIT