From 69c82f63b5b50a0a448b2262aa001d4e06165fa8 Mon Sep 17 00:00:00 2001 From: dead_horse Date: Sun, 13 Apr 2014 10:23:57 +0800 Subject: [PATCH] fix length when .body is missing --- lib/application.js | 2 ++ test/application.js | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/application.js b/lib/application.js index 12c3ea0..0020bbc 100644 --- a/lib/application.js +++ b/lib/application.js @@ -190,6 +190,8 @@ function *respond(next) { // status body this.type = 'text'; body = status[code]; + if (body) this.length = Buffer.byteLength(body); + return res.end(body); } // Buffer body diff --git a/test/application.js b/test/application.js index 8e0e25f..8ee040c 100644 --- a/test/application.js +++ b/test/application.js @@ -288,6 +288,7 @@ describe('app.respond', function(){ request(server) .get('/') .expect(400) + .expect('Content-Length', 11) .expect('Bad Request', done); }) })