This commit is contained in:
TJ Holowaychuk 2014-04-15 08:39:40 -07:00
parent 4e44c1c49e
commit 74cb04e7c1

View file

@ -168,6 +168,7 @@ function *respond(next) {
yield *next;
// allow bypassing koa
if (false === this.respond) return;
var res = this.res;
@ -188,21 +189,17 @@ function *respond(next) {
return res.end();
}
if (null == body) {
// status body
if (null == body) {
this.type = 'text';
body = status[code];
if (body) this.length = Buffer.byteLength(body);
return res.end(body);
}
// Buffer body
// responses
if (Buffer.isBuffer(body)) return res.end(body);
// string body
if ('string' == typeof body) return res.end(body);
// Stream body
if (body instanceof Stream) return body.pipe(res);
// body: json