Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Respond with valid XML even during an error condition

  • Loading branch information...
commit 5d3c1f1aa7284f682f1ad1bf40efa3f1d3d03ae6 1 parent 0bf1601
@dhruvbird authored
Showing with 11 additions and 5 deletions.
  1. +11 −5 src/http-server.js
View
16 src/http-server.js
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.