Coder Social home page Coder Social logo

h2url's Introduction

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..] URL

Options:

  -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
'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

h2url's People

Contributors

delvedor avatar eomm avatar mcollina avatar phra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

h2url's Issues

CLI not working

I have this error when use h2url CLI:

$ ./node_modules/h2url/h2url.js https://127.0.0.1:3000
/usr/bin/env: ‘node --no-warnings’: No such file or directory

But /usr/bin/env node --no-warnings works if I write it in my shell.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.