Comparing version 0.12.2 to 0.13.0
@@ -7,11 +7,11 @@ /** | ||
var Emitter = require('events').EventEmitter; | ||
var onFinished = require('on-finished'); | ||
var response = require('./response'); | ||
var compose = require('koa-compose'); | ||
var isJSON = require('koa-is-json'); | ||
var response = require('./response'); | ||
var context = require('./context'); | ||
var request = require('./request'); | ||
var onFinished = require('on-finished'); | ||
var statuses = require('statuses'); | ||
var Cookies = require('cookies'); | ||
var accepts = require('accepts'); | ||
var status = require('statuses'); | ||
var assert = require('assert'); | ||
@@ -191,3 +191,3 @@ var Stream = require('stream'); | ||
// ignore body | ||
if (status.empty[code]) { | ||
if (statuses.empty[code]) { | ||
// strip headers | ||
@@ -206,3 +206,3 @@ this.body = null; | ||
this.type = 'text'; | ||
body = status[code]; | ||
body = this.message || String(code); | ||
if (body) this.length = Buffer.byteLength(body); | ||
@@ -209,0 +209,0 @@ return res.end(body); |
@@ -9,4 +9,4 @@ | ||
var delegate = require('delegates'); | ||
var statuses = require('statuses'); | ||
var assert = require('assert'); | ||
var http = require('http'); | ||
@@ -130,6 +130,6 @@ /** | ||
// default to 500 | ||
if ('number' != typeof err.status || !http.STATUS_CODES[err.status]) err.status = 500; | ||
if ('number' != typeof err.status || !statuses[err.status]) err.status = 500; | ||
// respond | ||
var code = http.STATUS_CODES[err.status]; | ||
var code = statuses[err.status]; | ||
var msg = err.expose ? err.message : code; | ||
@@ -153,2 +153,3 @@ this.status = err.status; | ||
.access('status') | ||
.access('message') | ||
.access('body') | ||
@@ -155,0 +156,0 @@ .access('length') |
@@ -8,7 +8,7 @@ | ||
var getType = require('mime-types').contentType; | ||
var onFinish = require('on-finished'); | ||
var isJSON = require('koa-is-json'); | ||
var escape = require('escape-html'); | ||
var onFinish = require('on-finished'); | ||
var typeis = require('type-is').is; | ||
var status = require('statuses'); | ||
var statuses = require('statuses'); | ||
var destroy = require('destroy'); | ||
@@ -73,9 +73,32 @@ var assert = require('assert'); | ||
assert('number' == typeof code, 'status code must be a number'); | ||
assert(http.STATUS_CODES[code], 'invalid status code: ' + code); | ||
assert(statuses[code], 'invalid status code: ' + code); | ||
this._explicitStatus = true; | ||
this.res.statusCode = code; | ||
if (this.body && status.empty[code]) this.body = null; | ||
this.res.statusMessage = statuses[code]; | ||
if (this.body && statuses.empty[code]) this.body = null; | ||
}, | ||
/** | ||
* Get response status message | ||
* | ||
* @return {String} | ||
* @api public | ||
*/ | ||
get message() { | ||
return this.res.statusMessage || statuses[this.status]; | ||
}, | ||
/** | ||
* Set response status message | ||
* | ||
* @param {String} msg | ||
* @api public | ||
*/ | ||
set message(msg) { | ||
this.res.statusMessage = msg; | ||
}, | ||
/** | ||
* Get response body. | ||
@@ -104,3 +127,3 @@ * | ||
if (null == val) { | ||
if (!status.empty[this.status]) this.status = 204; | ||
if (!statuses.empty[this.status]) this.status = 204; | ||
this.res.removeHeader('Content-Type'); | ||
@@ -229,3 +252,3 @@ this.res.removeHeader('Content-Length'); | ||
// status | ||
if (!status.redirect[this.status]) this.status = 302; | ||
if (!statuses.redirect[this.status]) this.status = 302; | ||
@@ -458,3 +481,3 @@ // html | ||
status: this.status, | ||
string: http.STATUS_CODES[this.status], | ||
message: this.message, | ||
header: this.header | ||
@@ -461,0 +484,0 @@ } |
{ | ||
"name": "koa", | ||
"version": "0.12.2", | ||
"version": "0.13.0", | ||
"description": "Koa web app framework", | ||
@@ -56,6 +56,4 @@ "main": "lib/application.js", | ||
"files": [ | ||
"lib", | ||
"LICENSE", | ||
"History.md" | ||
"lib" | ||
] | ||
} |
@@ -84,2 +84,3 @@ <img src="https://dl.dropboxusercontent.com/u/6396913/koa/logo.png" alt="koa middleware framework for nodejs" width="255px" /> | ||
- [Julian Gruber](https://github.com/juliangruber) | ||
- [Yiyu He](https://github.com/dead-horse) | ||
@@ -90,7 +91,7 @@ # License | ||
[npm-image]: https://img.shields.io/npm/v/koa.svg?style=flat | ||
[npm-image]: https://img.shields.io/npm/v/koa.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/koa | ||
[travis-image]: https://img.shields.io/travis/koajs/koa.svg?style=flat | ||
[travis-image]: https://img.shields.io/travis/koajs/koa.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/koajs/koa | ||
[coveralls-image]: https://img.shields.io/coveralls/koajs/koa.svg?style=flat | ||
[coveralls-image]: https://img.shields.io/coveralls/koajs/koa.svg?style=flat-square | ||
[coveralls-url]: https://coveralls.io/r/koajs/koa?branch=master |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1266
96
4
34859
6