GithubHelp home page GithubHelp logo

dbrain / bagofrequest Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cliffano/bagofrequest

1.0 2.0 0.0 84 KB

A bag-of-holding containing request utility functions.

License: MIT License

JavaScript 100.00%

bagofrequest's Introduction

Bag Of Request Build Status Dependencies Status Published Version

Avatar

Bag Of Request contains request utility functions.

bag.request uses http://github.com/mikeal/request, with:

  • proxy setting based on environment variables http_proxy, HTTP_PROXY, https_proxy, HTTPS_PROXY
  • excludes proxy if URL host is localhost or 127.0.0.1
  • thirty seconds default timeout
  • accepts self-signed SSL certificates
  • follow redirects by default
  • wildcard status code matching (e.g. 2xx, 50x)
  • custom handlers based on status code
  • default unexpected status code error with request body included in message
  • all bag.request defaults can be overriden by passing mikeal/request options
  • retry support with configurable delay

bag.proxy is a convenient function to retrieve proxy based on URL and environment value:

  • if URL uses http, then sets proxy to http_proxy or HTTP_PROXY
  • if URL uses https, then sets proxy to htps_proxy or HTTPS_PROXY or http_proxy or HTTP_PROXY
  • if URL does not have a protocol, then assume http protocol
  • if URL is not provided, then sets proxy to http_proxy or HTTP_PROXY or https_proxy or HTTPS_PROXY

Installation

npm install bagofrequest

or as a dependency in package.json file:

"dependencies": {
  "bagofrequest": "x.y.z"
}

Usage

var bag = require('bagofrequest');

bag.request('get', 'http://google.com.au', { timeout: 30000 }, function (err, result) {
});

var proxy = bag.proxy('https://google.com.au');

bagofrequest's People

Contributors

cliffano avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.