From 491cef3cd6c809d44a81081ec2394af9f0cf981f Mon Sep 17 00:00:00 2001 From: Lukas Froeschl Date: Tue, 13 Jun 2017 10:18:40 +0200 Subject: [PATCH 1/2] Added handling for unknown HTTP-StatusCodes --- lib/server-response.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/server-response.js b/lib/server-response.js index 538b40e..66d770d 100644 --- a/lib/server-response.js +++ b/lib/server-response.js @@ -42,10 +42,11 @@ class ServerResponse { * @return {object} response - object suitable for sending via HTTP */ createResponseObject(httpCode, resultPayload) { + let status = ServerResponse.STATUS[httpCode] || { STATUS: [`${httpCode}`, `Unknown statusCode ${httpCode}`]} let response = Object.assign({ statusCode: httpCode, - statusMessage: ServerResponse.STATUS[httpCode][ServerResponse.STATUSMESSAGE], - statusDescription: ServerResponse.STATUS[httpCode][ServerResponse.STATUSDESCRIPTION], + statusMessage: status[ServerResponse.STATUSMESSAGE], + statusDescription: status[ServerResponse.STATUSDESCRIPTION], result: {} }, resultPayload || {}); return response; From c3bbba9ab8dd86054cd76c65272006c5bf07713c Mon Sep 17 00:00:00 2001 From: Lukas Froeschl Date: Tue, 13 Jun 2017 10:20:11 +0200 Subject: [PATCH 2/2] fix --- lib/server-response.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server-response.js b/lib/server-response.js index 66d770d..853a6e2 100644 --- a/lib/server-response.js +++ b/lib/server-response.js @@ -42,7 +42,7 @@ class ServerResponse { * @return {object} response - object suitable for sending via HTTP */ createResponseObject(httpCode, resultPayload) { - let status = ServerResponse.STATUS[httpCode] || { STATUS: [`${httpCode}`, `Unknown statusCode ${httpCode}`]} + let status = ServerResponse.STATUS[httpCode] || [`${httpCode}`, `Unknown statusCode ${httpCode}`]; let response = Object.assign({ statusCode: httpCode, statusMessage: status[ServerResponse.STATUSMESSAGE],