Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Check that it survives content-length=0 and content-type=application/json #821

Merged
merged 1 commit into from

2 participants

@darobin

See #815.

@tj tj merged commit 8b40ba6 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 7, 2013
  1. @darobin

    add a test to check that connect properly survives content-length=0 a…

    darobin authored
    …nd content-type=application/json (see senchalabs#815)
This page is out of date. Refresh to see the latest.
Showing with 19 additions and 0 deletions.
  1. +19 −0 test/json.js
View
19 test/json.js
@@ -41,6 +41,25 @@ describe('connect.json()', function(){
});
})
+ it('should handle Content-Length: 0', function(done){
+ var app = connect();
+ app.use(connect.json());
+
+ app.use(function(req, res){
+ res.end('req.body is ' + (Object.keys(req.body).length === 0 ? '' : 'not ') + 'empty');
+ });
+
+ app.request()
+ .get('/')
+ .set('Content-Type', 'application/json')
+ .set('Content-Length', '0')
+ .end(function(res){
+ res.should.have.status(200);
+ res.body.should.equal('req.body is empty');
+ done();
+ });
+ })
+
it('should 400 on malformed JSON', function(done){
var app = connect();
app.use(connect.json());
Something went wrong with that request. Please try again.