Commit 8f3c6dd9 authored by xzj's avatar xzj

优化agent判断

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