Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tweak coding and commenting style

  • Loading branch information...
commit 5f742307a54b856865bbdd39a170c05d8597ed08 1 parent fbe9e0c
@evdb evdb authored
Showing with 3 additions and 5 deletions.
  1. +2 −4 lib/middleware/json.js
  2. +1 −1  test/json.js
View
6 lib/middleware/json.js
@@ -67,10 +67,8 @@ exports = module.exports = function(options){
req.on('end', function(){
var first = buf.trim()[0];
- if ( buf.length == 0 ) {
- // content-type says json, but no body. Provide specific error message to help
- // debug. This is often due to a library not creating valid requests.
- return next( utils.error( 400, "invalid json - request content-type is 'application/json' but request body empty") );
+ if (0 == buf.length) {
+ return next(utils.error(400, "invalid json, empty body"));
}
if (strict && '{' != first && '[' != first) return next(utils.error(400, 'invalid json'));
View
2  test/json.js
@@ -69,7 +69,7 @@ describe('connect.json()', function(){
.set('Content-Type', 'application/json')
.end(function(res) {
res.should.have.status(400);
- res.body.should.include("invalid json - request content-type is 'application/json' but request body empty");
+ res.body.should.include("invalid json, empty body");
done();
})
})
Please sign in to comment.
Something went wrong with that request. Please try again.