Commit 86e30abe authored by xzj's avatar xzj

统计url为uri

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