How to use the needle.defaults function in needle

To help you get started, we’ve selected a few needle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Ireoo / spider.npm / test / net.js View on Github external
};
            this.cb = function() {}
        }
        //实列化一个最大并发为1的队列
        this.queue = new Queue(this.init.threads,{
            "queueStart": function(queue){}
            ,"queueEnd": function(queue){}
            ,"workAdd": function(item, queue){}
            ,"workResolve": function(value, queue){}
            ,"workReject": function(reason, queue){}
            ,"workFinally": function(queue){}
            ,"retry": this.init.retry               //Number of retries
            ,"retryIsJump": this.init.retryIsJump     //retry now?
            ,"timeout": this.init.timeout           //The timeout period
        });
        needle.defaults({
            // open_timeout: this.init.timeout,
            // read_timeout: this.init.timeout,
            // timeout: this.init.timeout,
            user_agent: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)'
        });
        if (options.run) this.run(options.links);
        return this;
    }
github mapbox / geojson-mapnikify / lib / get.js View on Github external
function getClientSettings() {
  module.exports.requestClient ?
    module.exports.requestClient :
    needle.defaults({
      response_timeout: 4000,
      follow_max: 1
    });
  return needle;
}
github itchio / itch / appsrc / promised / needle.js View on Github external
import Promise from 'bluebird'
import needle from 'needle'
import invariant from 'invariant'

import useragent from '../constants/useragent'

const proxy = process.env.http_proxy || process.env.HTTP_PROXY
const proxySource = proxy ? 'env' : 'direct'

needle.defaults({
  proxy,
  user_agent: useragent
})

const err = new Error('Offline mode active!')
err.code = 'ENOTFOUND'

function isOffline () {
  const store = require('../store').default
  if (store) {
    return store.getState().preferences.offlineMode
  } else {
    return false
  }
}
github prey / prey-node-client / lib / agent / transports / http / index.js View on Github external
exports.defaults = function(opts) {
  return needle.defaults(opts);
}

needle

The leanest and most handsome HTTP client in the Nodelands.

MIT
Latest version published 12 months ago

Package Health Score

74 / 100
Full package analysis