Skip to content

Commit

Permalink
Do not throw exception on double headers send. Just log error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Kotenko committed May 26, 2015
1 parent dba9e1b commit 1909368
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions blocks/i-response/i-response.priv.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ BEM.decl('i-response', null, {
*/
redirect: function (path) {
var res = this._getResponse();

if (res.finished) {
console.log('Cannot finish response. It is already finished.');
return;
}

res.writeHead(302, {'Location': path});
res.end();
},
Expand All @@ -89,6 +95,11 @@ BEM.decl('i-response', null, {
if (statusCode >= 500 && statusCode < 600) {
console.error(err);
}

if (res.finished) {
console.log('Cannot finish response. It is already finished.');
}

res.writeHead(statusCode, err.message);
res.end();
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bem-node",
"version": "0.9.5",
"version": "0.9.6",
"description": "",
"keywords": [
"bem",
Expand Down

0 comments on commit 1909368

Please sign in to comment.