Commit 86e30abe authored by xzj's avatar xzj

统计url为uri

parent 83c55103
...@@ -62,7 +62,7 @@ module.exports = function (options) { ...@@ -62,7 +62,7 @@ module.exports = function (options) {
ctx.req.connection.setNoDelay(true) ctx.req.connection.setNoDelay(true)
ctx.curl = function (option, extra) { ctx.curl = function (option, extra) {
if (typeof option === 'string') { if (typeof option === 'string') {
option = {url: option} option = {uri: option}
} }
if (!option.method) { if (!option.method) {
...@@ -73,14 +73,14 @@ module.exports = function (options) { ...@@ -73,14 +73,14 @@ module.exports = function (options) {
extra = Object.assign({}, extraDefault, extra) extra = Object.assign({}, extraDefault, extra)
if (!isProduction && ctx.request.query['_ip_']) { if (!isProduction && ctx.request.query['_ip_']) {
option.url = rewriteUrl(option.url, ctx.request.query._ip_) option.uri = rewriteUrl(option.uri, ctx.request.query._ip_)
} }
debug(option) debug(option)
if (!option.agent && !/^https/.test(option.url)) { if (!option.agent && !/^https/.test(option.uri)) {
option.agent = httpAgent option.agent = httpAgent
} else if (!option.agent && /^https/.test(option.url)) { } else if (!option.agent && /^https/.test(option.uri)) {
option.agent = httpsAgent option.agent = httpsAgent
} }
...@@ -105,28 +105,28 @@ module.exports = function (options) { ...@@ -105,28 +105,28 @@ module.exports = function (options) {
ctx.pipe = function (option) { ctx.pipe = function (option) {
if (typeof option === 'string') { if (typeof option === 'string') {
option = {url: option} option = {uri: option}
} }
option = Object.assign({}, pipeDefault, option) option = Object.assign({}, pipeDefault, option)
if (!isProduction && ctx.request.query['_ip_']) { if (!isProduction && ctx.request.query['_ip_']) {
option.url = rewriteUrl(option.url, ctx.request.query._ip_) option.uri = rewriteUrl(option.uri, ctx.request.query._ip_)
} }
if (!option.method) { if (!option.method) {
option.method = ctx.method option.method = ctx.method
} }
if (!option.agent && !/^https/.test(option.url)) { if (!option.agent && !/^https/.test(option.uri)) {
option.agent = httpAgent option.agent = httpAgent
} else if (!option.agent && /^https/.test(option.url)) { } else if (!option.agent && /^https/.test(option.uri)) {
option.agent = httpsAgent option.agent = httpsAgent
} }
let send = function () { let send = function () {
return request(option, function (err, response) { return request(option, function (err, response) {
if (option.time && options.logger) { if (option.time && options.logger) {
options.logger.info(option.url || option.uri, JSON.stringify(response && response.timings || '')) options.logger.info(option.uri, JSON.stringify(response && response.timings || ''))
} }
}) })
} }
......
{ {
"name": "request-proxy", "name": "request-proxy",
"version": "2.0.1", "version": "2.0.2",
"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