Skip to content

Commit

Permalink
Updating the default onerror handler with a Content-Type header
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Jun 30, 2016
1 parent 37f7b47 commit 53ce720
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/woodland.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Woodland {
status = numeric ? Number(err.message) : 500,
body = numeric ? http.STATUS_CODES[status] : err.message;

res.writeHead(status);
res.writeHead(status, {"Content-Type": "text/plain"});
res.end(body);
};
this.onfinish = () => {};
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": "woodland",
"version": "1.0.5",
"version": "1.0.6",
"description": "Lightweight HTTP/HTTPS router with virtual hosts",
"main": "index.js",
"scripts": {
Expand Down
11 changes: 11 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe("Invalid Requests", function () {
.expectStatus(405)
.expectHeader("Allow", "GET, HEAD, OPTIONS")
.expectHeader("Cache-Control", "no-cache")
.expectHeader("Content-Type", "text/plain")
.expectBody(/Method Not Allowed/)
.end(function (err) {
if (err) throw err;
Expand All @@ -72,6 +73,7 @@ describe("Invalid Requests", function () {
.expectStatus(405)
.expectHeader("Allow", "GET, HEAD, OPTIONS")
.expectHeader("Cache-Control", "no-cache")
.expectHeader("Content-Type", "text/plain")
.expectBody(/Method Not Allowed/)
.end(function (err) {
if (err) throw err;
Expand All @@ -85,6 +87,7 @@ describe("Invalid Requests", function () {
.expectStatus(405)
.expectHeader("Allow", "GET, HEAD, OPTIONS")
.expectHeader("Cache-Control", "no-cache")
.expectHeader("Content-Type", "text/plain")
.expectBody(/Method Not Allowed/)
.end(function (err) {
if (err) throw err;
Expand All @@ -98,6 +101,7 @@ describe("Invalid Requests", function () {
.expectStatus(405)
.expectHeader("Allow", "GET, HEAD, OPTIONS")
.expectHeader("Cache-Control", "no-cache")
.expectHeader("Content-Type", "text/plain")
.expectBody(/Method Not Allowed/)
.end(function (err) {
if (err) throw err;
Expand All @@ -111,6 +115,7 @@ describe("Invalid Requests", function () {
.expectStatus(404)
.expectHeader("Allow", undefined)
.expectHeader("Cache-Control", "no-cache")
.expectHeader("Content-Type", "text/plain")
.expectBody(/Not Found/)
.end(function (err) {
if (err) throw err;
Expand All @@ -124,6 +129,7 @@ describe("Invalid Requests", function () {
.expectStatus(404)
.expectHeader("Allow", undefined)
.expectHeader("Cache-Control", "no-cache")
.expectHeader("Content-Type", "text/plain")
.expectBody(/Not Found/)
.end(function (err) {
if (err) throw err;
Expand All @@ -137,6 +143,7 @@ describe("Invalid Requests", function () {
.expectStatus(404)
.expectHeader("Allow", undefined)
.expectHeader("Cache-Control", "no-cache")
.expectHeader("Content-Type", "text/plain")
.expectBody(/Not Found/)
.end(function (err) {
if (err) throw err;
Expand All @@ -151,6 +158,7 @@ describe("Invalid Requests", function () {
.expectStatus(404)
.expectHeader("Allow", undefined)
.expectHeader("Cache-Control", "no-cache")
.expectHeader("Content-Type", "text/plain")
.expectBody(/Not Found/)
.end(function (err) {
if (err) throw err;
Expand All @@ -164,6 +172,7 @@ describe("Invalid Requests", function () {
.expectStatus(404)
.expectHeader("Allow", undefined)
.expectHeader("Cache-Control", "no-cache")
.expectHeader("Content-Type", "text/plain")
.expectBody(/Not Found/)
.end(function (err) {
if (err) throw err;
Expand All @@ -177,6 +186,7 @@ describe("Invalid Requests", function () {
.expectStatus(404)
.expectHeader("Allow", undefined)
.expectHeader("Cache-Control", "no-cache")
.expectHeader("Content-Type", "text/plain")
.expectBody(/Not Found/)
.end(function (err) {
if (err) throw err;
Expand All @@ -190,6 +200,7 @@ describe("Invalid Requests", function () {
.expectStatus(404)
.expectHeader("Allow", undefined)
.expectHeader("Cache-Control", "no-cache")
.expectHeader("Content-Type", "text/plain")
.expectBody(/Not Found/)
.end(function (err) {
if (err) throw err;
Expand Down

0 comments on commit 53ce720

Please sign in to comment.