refactor res.status=
This commit is contained in:
parent
ed8beb7d79
commit
696d55d73b
1 changed files with 3 additions and 5 deletions
|
@ -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;
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue