Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function respond(ctx) {
// allow bypassing koa
if (false === ctx.respond) return;

if (!ctx.writable) return;
if (!ctx.writable) return ctx.res.end();

const res = ctx.res;
let body = ctx.body;
Expand All @@ -267,23 +267,23 @@ function respond(ctx) {
if (statuses.empty[code]) {
// strip headers
ctx.body = null;
return res.end();
return ctx.res.end();
}

if ('HEAD' === ctx.method) {
if (!res.headersSent && !ctx.response.has('Content-Length')) {
const { length } = ctx.response;
if (Number.isInteger(length)) ctx.length = length;
}
return res.end();
return ctx.res.end();
}

// status body
if (null == body) {
if (ctx.response._explicitNullBody) {
ctx.response.remove('Content-Type');
ctx.response.remove('Transfer-Encoding');
return res.end();
return ctx.res.end();
}
if (ctx.req.httpVersionMajor >= 2) {
body = String(code);
Expand Down
Loading