Commit 6c8b87b8 authored by xzj's avatar xzj

修复uri

parent 50ec3daa
...@@ -63,7 +63,7 @@ module.exports = function (options) { ...@@ -63,7 +63,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) {
...@@ -74,7 +74,11 @@ module.exports = function (options) { ...@@ -74,7 +74,11 @@ 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_']) if (option.url) {
option.url = rewriteUrl(option.url, ctx.request.query['_ip_'])
} else {
option.uri = rewriteUrl(option.uri, ctx.request.query['_ip_'])
}
} }
debug(option) debug(option)
...@@ -106,12 +110,16 @@ module.exports = function (options) { ...@@ -106,12 +110,16 @@ 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_']) if (option.url) {
option.url = rewriteUrl(option.url, ctx.request.query['_ip_'])
} else {
option.uri = rewriteUrl(option.uri, ctx.request.query['_ip_'])
}
} }
if (!option.method) { if (!option.method) {
......
{ {
"name": "request-proxy", "name": "request-proxy",
"version": "1.1.1", "version": "1.1.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