Permalink
Browse files

Respond with valid XML even during an error condition

  • Loading branch information...
1 parent 0bf1601 commit 5d3c1f1aa7284f682f1ad1bf40efa3f1d3d03ae6 @dhruvbird committed Aug 30, 2012
Showing with 11 additions and 5 deletions.
  1. +11 −5 src/http-server.js
View
@@ -101,9 +101,12 @@ function HTTPServer(port, host, stat_func, bosh_request_handler, http_error_hand
var body = parse_request([u.query.data]);
if (body === null) {
- // FIXME: If we got an invalid JSON, we should respond
- // with an error condition.
- res.end("XML Parsing Error!");
+ // If we got an invalid JSON, we should respond with
+ // valid XML that has an error condition.
+ res.end(helper.$terminate({
+ condition: "bad-request",
+ message: "Invalid XML"
+ }).toString());
} else {
bosh_request_handler(res, body);
}
@@ -136,8 +139,11 @@ function HTTPServer(port, host, stat_func, bosh_request_handler, http_error_hand
req_parts.forEach(function (p) {
log.warn("XML parsing Error: %s", p);
});
- // FIXME: Send back valid XML.
- res.end("XML parsing Error");
+ // Send back valid XML with an appropriate error code.
+ res.end(helper.$terminate({
+ condition: "bad-request",
+ message: "Invalid XML"
+ }).toString());
}
}
req_parts = null;

0 comments on commit 5d3c1f1

Please sign in to comment.