diff --git a/package.json b/package.json index 11318b888f..bde4b15c66 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "graceful": "^1.1.0", "humanize-ms": "^1.2.1", "is-type-of": "^1.2.1", - "koa-bodyparser": "^4.3.0", + "koa-bodyparser": "^4.4.1", "koa-is-json": "^1.0.0", "koa-override": "^3.0.0", "ms": "^2.1.3", diff --git a/test/app/middleware/body_parser.test.js b/test/app/middleware/body_parser.test.js index 6c4a6999cf..c0a60dd433 100644 --- a/test/app/middleware/body_parser.test.js +++ b/test/app/middleware/body_parser.test.js @@ -50,6 +50,18 @@ describe('test/app/middleware/body_parser.test.js', () => { .expect(200); }); + // fix https://github.com/eggjs/egg/issues/5214 + it('should 200 when post json with `content-type: application/json;charset=utf-8;`', () => { + app.mockCsrf(); + return app.httpRequest() + .post('/test/body_parser/user') + .set('Cookie', cookies) + .set('Content-Type', 'application/json;charset=utf-8;') + .send({ test: 1 }) + .expect({ test: 1 }) + .expect(200); + }); + it('should 200 when post json body below the limit', () => { return app.httpRequest() .post('/test/body_parser/user')