1
0
mirror of https://github.com/balkian/go5ears.git synced 2024-11-25 14:42:27 +00:00

Safely parse the response from goear (avoid resets)

This commit is contained in:
J.Fernando Sánchez 2012-11-08 14:28:29 +01:00
parent 1cf3f5d803
commit 62eff02fee

View File

@ -74,16 +74,18 @@ app.get('/play', function(req,resp){
parser.parseString(xml, function(err,result){
console.log("xml: "+xml);
console.log("Object: "+JSON.stringify(result));
var song = result['songs']['song'][0]["$"];
console.log("Song:"+JSON.stringify(song));
var path = song['path'];
var title = song['title'];
var artist = song['artist'];
console.log(title + " - " +artist+" - "+path);
resp.writeHead(302, {
'Location': path
//add other headers here...
});
try{
var song = result['songs']['song'][0]["$"];
console.log("Song:"+JSON.stringify(song));
var path = song['path'];
var title = song['title'];
var artist = song['artist'];
console.log(title + " - " +artist+" - "+path);
resp.writeHead(302, {
'Location': path
//add other headers here...
});
}
resp.end();
});
});