Commit 28fbaf61 authored by xzj's avatar xzj

增加timeout配置

parent 756a043a
......@@ -18,7 +18,7 @@ module.exports = function (options) {
// 空闲的 KeepAlive socket 最长可以存活30秒
freeSocketKeepAliveTimeout: 30000
},
timeout: 15000 // 15秒超时
timeout: 15000
}
options = Object.assign({}, optionsDefault, options)
......@@ -30,7 +30,8 @@ module.exports = function (options) {
const curlDefault = {
followRedirect: false,
json: true,
time: false
time: false,
timeout: options.timeout
}
/**
......@@ -43,7 +44,8 @@ module.exports = function (options) {
}
const pipeDefault = {
time: false
time: false,
timeout: options.timeout
}
const httpAgent = new Agent(options.agent);
......@@ -110,7 +112,7 @@ module.exports = function (options) {
option.agent = httpsAgent
}
return new Promise(function (resolve, reject) {
let r = ctx.req.pipe(requestEx(option))
let r = ctx.req.pipe(request(option))
r.on('error', function (err) {
reject(err);
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment