Skip to content

Commit

Permalink
Setting content-type header within error() instead of passing it …
Browse files Browse the repository at this point in the history
…to `send()` which is a coherence issue for `onsend()`
  • Loading branch information
avoidwork committed Jan 3, 2021
1 parent 9da80f8 commit 305f4aa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/woodland.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ class Woodland extends EventEmitter {
const ev = "error";

if (res.headersSent === false) {
const headers = {"content-type": "text/plain; charset=utf-8"},
numeric = isNaN(err.message) === false,
const numeric = isNaN(err.message) === false,
status = isNaN(res.statusCode) === false && res.statusCode >= 400 ? res.statusCode : numeric ? Number(err.message) : 500,
output = numeric ? http.STATUS_CODES[status] : err.message;

Expand All @@ -230,7 +229,8 @@ class Woodland extends EventEmitter {
}
}

res.send(output, status, headers);
res.header("content-type", "text/plain; charset=utf-8");
res.send(output, status);
}

if (this.listenerCount(ev) > 0) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "woodland",
"version": "16.0.2",
"version": "16.0.3",
"description": "Lightweight HTTP router with automatic headers",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 305f4aa

Please sign in to comment.