From 33e28d4eccc888eb96132c66895a3921173c9bb1 Mon Sep 17 00:00:00 2001 From: David Henderson Date: Fri, 16 Dec 2011 10:29:13 +0000 Subject: [PATCH] Added buffer pass-through if we need to pass through binary data --- lib/journey.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/journey.js b/lib/journey.js index f41c9fa..8a8134e 100644 --- a/lib/journey.js +++ b/lib/journey.js @@ -176,11 +176,15 @@ journey.Router.prototype = { outcome.headers["Server"] = "journey/" + journey.version.join('.'); if (outcome.body) { - if (typeof(outcome.body) !== 'string') { - outcome.headers["Content-Type"] = "application/json;charset=utf-8"; - outcome.body = JSON.stringify(outcome.body); + if (Buffer.isBuffer(outcome.body)) { + outcome.headers['Content-Length'] = outcome.body.length; + }else{ + if (typeof(outcome.body) !== 'string') { + outcome.headers["Content-Type"] = "application/json;charset=utf-8"; + outcome.body = JSON.stringify(outcome.body); + } + outcome.headers['Content-Length'] = Buffer.byteLength(outcome.body); } - outcome.headers['Content-Length'] = Buffer.byteLength(outcome.body); } else { delete(outcome.headers["Content-Type"]); }