Skip to content

Commit

Permalink
feat: allow bodyless responses for non empty status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Eladio Mora committed Apr 20, 2020
1 parent 8ddab48 commit 3254184
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/application.js
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions lib/response.js
Expand Up @@ -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');
Expand Down

0 comments on commit 3254184

Please sign in to comment.