Skip to content

Commit

Permalink
allow other messages to be processed even if 1 is bad
Browse files Browse the repository at this point in the history
  • Loading branch information
neonstalwart committed Jan 22, 2015
1 parent 36a516b commit 1fb86e2
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions media/message/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1fb86e2

Please sign in to comment.