Closed cncolder closed 7 years ago
https://github.com/node-webot/co-wechat/blob/6dbb669314fae9b74da5e994da94fcddffc78747/lib/wechat.js#L224-L228
var xml = await getRawBody(ctx.req, { length: ctx.length, limit: '1mb', encoding: ctx.charset });
此处的 ctx.length 是委托给 ctx.response.length 的,所以值是 undefined
ctx.length
ctx.response.length
undefined
ctx.charset 应该写成 ctx.request.charset 才对,并且按照 raw-body 文档,encoding: true 时默认为 'utf-8'。
ctx.charset
ctx.request.charset
raw-body
encoding: true
参见 https://github.com/koajs/koa/blob/aaac09af1a6aa02161fead1422fac460fbdcce3e/lib/context.js#L154-L208
所以我认为这里应该写成:
var xml = await getRawBody(ctx.req, { length: ctx.request.length, limit: '1mb', encoding: ctx.request.charset || 'utf-8' });
Try to use co-wechat@2.0.1
https://github.com/node-webot/co-wechat/blob/6dbb669314fae9b74da5e994da94fcddffc78747/lib/wechat.js#L224-L228
此处的
ctx.length
是委托给ctx.response.length
的,所以值是undefined
ctx.charset
应该写成ctx.request.charset
才对,并且按照raw-body
文档,encoding: true
时默认为 'utf-8'。参见 https://github.com/koajs/koa/blob/aaac09af1a6aa02161fead1422fac460fbdcce3e/lib/context.js#L154-L208
所以我认为这里应该写成: