From 294fd4e78524d1c6b6c9d79b36e72b93acb06867 Mon Sep 17 00:00:00 2001 From: Kees Kluskens Date: Mon, 19 Sep 2016 23:24:51 +0200 Subject: [PATCH 1/2] Don't assume `res._header` exist `res._header` is an internal implementation detail. Hence, some implementations of the http server do not set this. [node-spdy](https://github.com/indutny/node-spdy) is an example. --- src/webjs.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webjs.coffee b/src/webjs.coffee index c687af69..5cd7de92 100644 --- a/src/webjs.coffee +++ b/src/webjs.coffee @@ -120,7 +120,7 @@ exports.GenericApp = class GenericApp log_request: (req, res, data) -> td = (new Date()) - req.start_date @log('info', req.method + ' ' + req.url + ' ' + td + 'ms ' + - (if res.finished then res._header.split('\r')[0].split(' ')[1] \ + (if res.finished and res._header then res._header.split('\r')[0].split(' ')[1] \ else '(unfinished)')) return data From ffe222c489d144f6c83b28217b8df98ee10b7194 Mon Sep 17 00:00:00 2001 From: Kees Kluskens Date: Tue, 20 Sep 2016 00:00:38 +0200 Subject: [PATCH 2/2] Use `res.statusCode` instead of parsing internal property --- src/webjs.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/webjs.coffee b/src/webjs.coffee index 5cd7de92..42361c52 100644 --- a/src/webjs.coffee +++ b/src/webjs.coffee @@ -120,8 +120,7 @@ exports.GenericApp = class GenericApp log_request: (req, res, data) -> td = (new Date()) - req.start_date @log('info', req.method + ' ' + req.url + ' ' + td + 'ms ' + - (if res.finished and res._header then res._header.split('\r')[0].split(' ')[1] \ - else '(unfinished)')) + (if res.finished then res.statusCode else '(unfinished)')) return data log: (severity, line) ->