Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
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;
}
function getClientSettings() {
module.exports.requestClient ?
module.exports.requestClient :
needle.defaults({
response_timeout: 4000,
follow_max: 1
});
return needle;
}
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
}
}
exports.defaults = function(opts) {
return needle.defaults(opts);
}