Code Monkey home page Code Monkey logo

http2-request's Introduction

HTTP2 request

Greenkeeper badge

NPM Version Build Status Known Vulnerabilities

Http2 Request is designed to be the simplest way possible to make http & http2 calls. It supports HTTP2 and follows redirects by default.

To be http2 compatible it uses http2-client. To make requests it uses request - expect the API to be identical just with http2 support.

API

The API is identical to that of request as this module just changes the http modules of request - you will actually be using request. The only addition to the API is to disable this module behavior on request basis

const request = require('h2-request');
request({
  uri : 'http://www.google.com',
  disableHttp2 : true // <-- Now it's a regular request without http2
}, function (error, response, body) {
  console.log('error:', error); // Print the error if one occurred
  console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
  console.log('body:', body); // Print the HTML for the Google homepage.
});

Full API Documentation

To see the full API documentation: request Documentation

License

MIT

http2-request's People

Contributors

greenkeeper[bot] avatar hisco avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

http2-request's Issues

Invalid protocol ?

_http_client.js:131
    throw new ERR_INVALID_PROTOCOL(protocol, expectedProtocol);
    ^

TypeError [ERR_INVALID_PROTOCOL]: Protocol "http:" not supported. Expected "https:"
    at new ClientRequest (_http_client.js:131:11)
    at Object.request (http.js:41:10)
    at HttpsRequest.makeHttpRequest (/Users/eastkap/dev/nodemonitors/node_modules/http2-client/lib/request.js:396:31)
    at HttpsRequest.makeRequest (/Users/eastkap/dev/nodemonitors/node_modules/http2-client/lib/request.js:355:17)
    at HttpsRequest.onIdentification (/Users/eastkap/dev/nodemonitors/node_modules/http2-client/lib/request.js:281:24)
    at HttpsRequest.onIdentify (/Users/eastkap/dev/nodemonitors/node_modules/http2-client/lib/request.js:381:9)
    at TLSSocket.onConnect (/Users/eastkap/dev/nodemonitors/node_modules/http2-client/lib/request.js:459:9)
    at Object.onceWrapper (events.js:277:13)
    at TLSSocket.emit (events.js:189:13)
    at TLSSocket.onConnectSecure (_tls_wrap.js:1163:10)

when asking a website over https

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.