koa-body-parser
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -25,5 +25,5 @@ | ||
if (encoding || length) { | ||
if ((encoding || length) && !this.req._readableState.ended) { | ||
try { | ||
this.request.body = yield parse(this.request); | ||
this.request.body = yield parse(this.request, opts); | ||
} catch (err) { | ||
@@ -30,0 +30,0 @@ if (err.status !== 415 || !empty) |
{ | ||
"name": "koa-body-parser", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Parse request body into ctx.request.body", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -14,2 +14,5 @@ | ||
- `empty` whether to throw a 415 if the client has indicated there is a body but it cannot be parsed (default: `true`) | ||
- `length` length limit of the stream to pass to raw-body (default: `content-length`) | ||
- `limit` byte limit of the body to pass to raw-body, throws 413 if body is larger | ||
- `encoding` requested encoding (default: `utf8`) | ||
@@ -16,0 +19,0 @@ ## Example |
@@ -42,3 +42,21 @@ | ||
describe('empty body', function () { | ||
it('should allow body to be parsed twice', function (done) { | ||
var app = koa(); | ||
app.use(parseBody()); | ||
app.use(parseBody()); | ||
app.use(function *() { | ||
this.request.body.should.eql({ hello: 'world' });; | ||
this.status = 200; | ||
}); | ||
request(app.listen()) | ||
.post('/') | ||
.set('Content-Type', 'application/json') | ||
.send({ hello: 'world' }) | ||
.expect(200, done); | ||
}); | ||
describe('with an empty body', function () { | ||
it('should not throw when GET', function (done) { | ||
@@ -45,0 +63,0 @@ var app = koa(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
6372
9
121
42
0