refactor res.status=

This commit is contained in:
TJ Holowaychuk 2014-06-10 14:33:13 -07:00
parent ed8beb7d79
commit 696d55d73b

View file

@ -10,10 +10,10 @@ var escape = require('escape-html');
var onfinish = require('finished');
var status = require('statuses');
var destroy = require('dethroy');
var assert = require('assert');
var http = require('http');
var path = require('path');
var vary = require('vary');
var assert = require('assert');
var basename = path.basename;
var extname = path.extname;
@ -66,12 +66,10 @@ module.exports = {
*/
set status(code) {
assert(typeof code === 'number', 'status code must be a number');
if(!http.STATUS_CODES[code]) throw new Error('invalid status code: ' + code);
assert('number' == typeof code, 'status code must be a number');
assert(http.STATUS_CODES[code], 'invalid status code: ' + code);
this._explicitStatus = true;
this.res.statusCode = code;
if (this.body && status.empty[code]) this.body = null;
},