fix length when .body is missing
This commit is contained in:
parent
e8ba41df96
commit
69c82f63b5
2 changed files with 3 additions and 0 deletions
|
@ -190,6 +190,8 @@ function *respond(next) {
|
||||||
// status body
|
// status body
|
||||||
this.type = 'text';
|
this.type = 'text';
|
||||||
body = status[code];
|
body = status[code];
|
||||||
|
if (body) this.length = Buffer.byteLength(body);
|
||||||
|
return res.end(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Buffer body
|
// Buffer body
|
||||||
|
|
|
@ -288,6 +288,7 @@ describe('app.respond', function(){
|
||||||
request(server)
|
request(server)
|
||||||
.get('/')
|
.get('/')
|
||||||
.expect(400)
|
.expect(400)
|
||||||
|
.expect('Content-Length', 11)
|
||||||
.expect('Bad Request', done);
|
.expect('Bad Request', done);
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue