diff --git a/Include/osrm/Reply.h b/Include/osrm/Reply.h index 8e9b31750..82f2d2f41 100644 --- a/Include/osrm/Reply.h +++ b/Include/osrm/Reply.h @@ -37,8 +37,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace http { const char okHTML[] = ""; -const char badRequestHTML[] = "Bad Request

400 Bad Request

"; -const char internalServerErrorHTML[] = "Internal Server Error

500 Internal Server Error

"; +const char badRequestHTML[] = "{\"status\": 400,\"status_message\":\"Bad Request\"}"; +const char internalServerErrorHTML[] = "{\"status\": 500,\"status_message\":\"Internal Server Error\"}"; const char seperators[] = { ':', ' ' }; const char crlf[] = { '\r', '\n' }; const std::string okString = "HTTP/1.0 200 OK\r\n"; diff --git a/Server/RequestHandler.cpp b/Server/RequestHandler.cpp index ba6d20629..dc3b88aad 100644 --- a/Server/RequestHandler.cpp +++ b/Server/RequestHandler.cpp @@ -76,21 +76,15 @@ void RequestHandler::handle_request(const http::Request& req, http::Reply& rep){ if ( !result || (it != request.end()) ) { rep = http::Reply::StockReply(http::Reply::badRequest); + rep.content.clear(); const int position = std::distance(request.begin(), it); + rep.content.push_back( + "{\"status\":400,\"status_message\":\"Query string malformed close to position " + ); std::string tmp_position_string; intToString(position, tmp_position_string); - rep.content.push_back( - "Input seems to be malformed close to position " - "
"
-            );
-            rep.content.push_back( request );
             rep.content.push_back(tmp_position_string);
-            rep.content.push_back("
"); - const unsigned end = std::distance(request.begin(), it); - for(unsigned i = 0; i < end; ++i) { - rep.content.push_back(" "); - } - rep.content.push_back("^
"); + rep.content.push_back("\"}"); } else { //parsing done, lets call the right plugin to handle the request BOOST_ASSERT_MSG(