Comparing version 1.2.5 to 1.3.0
1.3.0 / 2017-03-07 | ||
================== | ||
* added: node v7.7+ `res.getHeaderNames()` support #913 | ||
* added: `err.headerSent` in error handling #923 | ||
1.2.5 / 2017-02-12 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -76,6 +76,4 @@ | ||
* this.throw(403) | ||
* this.throw('name required', 400) | ||
* this.throw(400, 'name required') | ||
* this.throw('something exploded') | ||
* this.throw(new Error('invalid'), 400); | ||
* this.throw(400, new Error('invalid')); | ||
@@ -110,2 +108,7 @@ * | ||
var headerSent = false; | ||
if (this.headerSent || !this.writable) { | ||
headerSent = err.headerSent = true; | ||
} | ||
// delegate | ||
@@ -117,9 +120,14 @@ this.app.emit('error', err, this); | ||
// handler and log. | ||
if (this.headerSent || !this.writable) { | ||
err.headerSent = true; | ||
if (headerSent) { | ||
return; | ||
} | ||
// unset all headers, and set those specified | ||
this.res._headers = {}; | ||
// first unset all headers | ||
if (this.res.getHeaderNames) { | ||
this.res.getHeaderNames().forEach(function(name) { this.removeHeader(name) }, this.res); | ||
} else { | ||
this.res._headers = {}; // Node < 8 | ||
} | ||
// then set those specified | ||
this.set(err.headers); | ||
@@ -126,0 +134,0 @@ |
@@ -47,3 +47,5 @@ | ||
get header() { | ||
return this.res._headers || {}; | ||
return this.res.getHeaders | ||
? this.res.getHeaders() | ||
: this.res._headers || {}; // Node < 8 | ||
}, | ||
@@ -50,0 +52,0 @@ |
{ | ||
"name": "koa", | ||
"version": "1.2.5", | ||
"version": "1.3.0", | ||
"description": "Koa web app framework", | ||
@@ -5,0 +5,0 @@ "main": "lib/application.js", |
@@ -31,3 +31,3 @@ <img src="https://dl.dropboxusercontent.com/u/6396913/koa/logo.png" alt="koa middleware framework for nodejs" width="255px" /> | ||
```bash | ||
npm install koa@2 | ||
npm install koa@next | ||
``` | ||
@@ -122,3 +122,3 @@ | ||
Support us with a monthly donation and help us continue our activities. | ||
Support us with a monthly donation and help us continue our activities. | ||
@@ -159,3 +159,3 @@ <a href="https://opencollective.com/koajs/backer/0/website" target="_blank"><img src="https://opencollective.com/koajs/backer/0/avatar.svg"></a> | ||
Become a sponsor and get your logo on our README on Github with a link to your site. | ||
Become a sponsor and get your logo on our README on Github with a link to your site. | ||
@@ -199,6 +199,6 @@ <a href="https://opencollective.com/koajs/sponsor/0/website" target="_blank"><img src="https://opencollective.com/koajs/sponsor/0/avatar.svg"></a> | ||
[npm-url]: https://www.npmjs.com/package/koa | ||
[travis-image]: https://img.shields.io/travis/koajs/koa/master.svg?style=flat-square | ||
[travis-image]: https://img.shields.io/travis/koajs/koa/v1.x.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/koajs/koa | ||
[coveralls-image]: https://img.shields.io/codecov/c/github/koajs/koa.svg?style=flat-square | ||
[coveralls-url]: https://codecov.io/github/koajs/koa?branch=master | ||
[coveralls-url]: https://codecov.io/github/koajs/koa?branch=v1.x | ||
[backers-image]: https://opencollective.com/koajs/backers/badge.svg?style=flat-square | ||
@@ -205,0 +205,0 @@ [sponsors-image]: https://opencollective.com/koajs/sponsors/badge.svg?style=flat-square |
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
57547
1363