diff --git a/lib/application.js b/lib/application.js index 57b701cef..ab711d294 100644 --- a/lib/application.js +++ b/lib/application.js @@ -238,6 +238,11 @@ function respond(ctx) { // status body if (null == body) { + if (ctx.response._explicitNullBody) { + ctx.response.remove('Content-Type'); + ctx.response.remove('Transfer-Encoding'); + return res.end(); + } if (ctx.req.httpVersionMajor >= 2) { body = String(code); } else { diff --git a/lib/response.js b/lib/response.js index 87ecc56a9..4f2fc2783 100644 --- a/lib/response.js +++ b/lib/response.js @@ -139,6 +139,7 @@ module.exports = { // no content if (null == val) { if (!statuses.empty[this.status]) this.status = 204; + this._explicitNullBody = true; this.remove('Content-Type'); this.remove('Content-Length'); this.remove('Transfer-Encoding');