From 1fb86e29300f704678c9f28315ae7cdceac26784 Mon Sep 17 00:00:00 2001 From: ben hockey Date: Thu, 22 Jan 2015 09:22:07 -0600 Subject: [PATCH] allow other messages to be processed even if 1 is bad --- media/message/json.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/media/message/json.js b/media/message/json.js index 5243aaf..9edbe68 100644 --- a/media/message/json.js +++ b/media/message/json.js @@ -32,26 +32,29 @@ module.exports = Media({ var responses = []; var clientConnection = getClientConnection(request); body.forEach(function(message){ + var response; + if (!message) { - return { - status: clientConnection.expectMore ? 202 : 200, + response = { headers: {}, - messages: true, + status: 400, body: [] }; } - - message.__proto__ = request; - if(!("to" in message)){ - message.to = ""; - } - var pathInfo = message.to.charAt(0) === '/' ? message.to : request.pathInfo.substring(0, request.pathInfo.lastIndexOf('/') + 1) + message.to; - while(lastPath !== pathInfo){ - var lastPath = pathInfo; - pathInfo = pathInfo.replace(/\/[^\/]*\/\.\.\//,'/'); + else { + message.__proto__ = request; + if(!("to" in message)){ + message.to = ""; + } + var pathInfo = message.to.charAt(0) === '/' ? message.to : request.pathInfo.substring(0, request.pathInfo.lastIndexOf('/') + 1) + message.to; + while(lastPath !== pathInfo){ + var lastPath = pathInfo; + pathInfo = pathInfo.replace(/\/[^\/]*\/\.\.\//,'/'); + } + message.pathInfo = pathInfo; + response = nextApp(message); } - message.pathInfo = pathInfo; - var response = nextApp(message); + responses.push(response); when(response, function(response){ response.pathInfo = pathInfo;