Commit 3948b207 authored by liuwei's avatar liuwei

修改 支持put

parent 86e30abe
...@@ -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 = {uri: option} option = { uri: option }
} }
if (!option.method) { if (!option.method) {
...@@ -85,7 +85,7 @@ module.exports = function (options) { ...@@ -85,7 +85,7 @@ module.exports = function (options) {
} }
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
request(option, function(err, response, body) { request(option, function (err, response, body) {
if (err) { if (err) {
if (extra.throw) { if (extra.throw) {
reject(err) reject(err)
...@@ -105,7 +105,7 @@ module.exports = function (options) { ...@@ -105,7 +105,7 @@ module.exports = function (options) {
ctx.pipe = function (option) { ctx.pipe = function (option) {
if (typeof option === 'string') { if (typeof option === 'string') {
option = {uri: option} option = { uri: option }
} }
option = Object.assign({}, pipeDefault, option) option = Object.assign({}, pipeDefault, option)
...@@ -131,7 +131,7 @@ module.exports = function (options) { ...@@ -131,7 +131,7 @@ module.exports = function (options) {
}) })
} }
if (ctx.method === 'POST' && ctx.is('json', 'urlencoded') && ctx.request.body) { if (ctx.is('json', 'urlencoded') && ctx.request.body) {
if (ctx.is('urlencoded')) { if (ctx.is('urlencoded')) {
option.form = ctx.request.rawBody option.form = ctx.request.rawBody
} else { } else {
......
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