Commit 3948b207 authored by liuwei's avatar liuwei

修改 支持put

parent 86e30abe
......@@ -62,7 +62,7 @@ module.exports = function (options) {
ctx.req.connection.setNoDelay(true)
ctx.curl = function (option, extra) {
if (typeof option === 'string') {
option = {uri: option}
option = { uri: option }
}
if (!option.method) {
......@@ -85,7 +85,7 @@ module.exports = function (options) {
}
return new Promise(function (resolve, reject) {
request(option, function(err, response, body) {
request(option, function (err, response, body) {
if (err) {
if (extra.throw) {
reject(err)
......@@ -105,7 +105,7 @@ module.exports = function (options) {
ctx.pipe = function (option) {
if (typeof option === 'string') {
option = {uri: option}
option = { uri: option }
}
option = Object.assign({}, pipeDefault, option)
......@@ -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')) {
option.form = ctx.request.rawBody
} else {
......@@ -145,9 +145,9 @@ module.exports = function (options) {
return new Promise(function (resolve, reject) {
let r = send()
r.on('error', function (err) {
console.error(err)
reject(err);
})
console.error(err)
reject(err);
})
.on('response', function () {
ctx.respond = false
r.pipe(ctx.res)
......@@ -160,9 +160,9 @@ module.exports = function (options) {
return new Promise(function (resolve, reject) {
let r = ctx.req.pipe(send())
r.on('error', function (err) {
console.error(err)
reject(err);
})
console.error(err)
reject(err);
})
.on('response', function () {
ctx.respond = false
r.pipe(ctx.res)
......
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