Commit 8f3c6dd9 authored by xzj's avatar xzj

优化agent判断

parent d24ad713
......@@ -69,10 +69,8 @@ module.exports = function (options) {
debug(option)
if (!option.agent && !/^https/.test(option.uri)) {
option.agent = httpAgent
} else if (!option.agent && /^https/.test(option.uri)) {
option.agent = httpsAgent
if (!option.agent) {
option.agent = option.uri.indexOf('https') === 0 ? httpsAgent : httpAgent
}
return new Promise(function (resolve, reject) {
......@@ -106,11 +104,10 @@ module.exports = function (options) {
debug(option)
if (!option.agent && !/^https/.test(option.uri)) {
option.agent = httpAgent
} else if (!option.agent && /^https/.test(option.uri)) {
option.agent = httpsAgent
if (!option.agent) {
option.agent = option.uri.indexOf('https') === 0 ? httpsAgent : httpAgent
}
return new Promise(function (resolve, reject) {
let r = ctx.req.pipe(request(option, function (err, response) {
if (option.time && options.logger) {
......
{
"name": "request-proxy",
"version": "1.2.0",
"version": "1.2.1",
"description": "",
"main": "index.js",
"scripts": {
......
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