mirror of https://gitee.com/bigwinds/arangodb
catch malformed input.
This commit is contained in:
parent
3d3fb23a62
commit
3beb3450b1
|
@ -79,7 +79,15 @@ inline HttpHandler::status_t RestAgencyHandler::redirect (id_t leader_id) {
|
|||
inline HttpHandler::status_t RestAgencyHandler::handleWrite () {
|
||||
arangodb::velocypack::Options options; // TODO: User not wait.
|
||||
if (_request->requestType() == HttpRequest::HTTP_REQUEST_POST) {
|
||||
write_ret_t ret = _agent->write (_request->toVelocyPack(&options));
|
||||
query_t query;
|
||||
try {
|
||||
query = _request->toVelocyPack(&options);
|
||||
} catch (std::exception const& e) {
|
||||
LOG(FATAL) << e.what();
|
||||
generateError(HttpResponse::UNPROCESSABLE_ENTITY,422);
|
||||
return HttpHandler::status_t(HANDLER_DONE);
|
||||
}
|
||||
write_ret_t ret = _agent->write (query);
|
||||
size_t errors = 0;
|
||||
if (ret.accepted) {
|
||||
Builder body;
|
||||
|
@ -111,7 +119,15 @@ inline HttpHandler::status_t RestAgencyHandler::handleWrite () {
|
|||
inline HttpHandler::status_t RestAgencyHandler::handleRead () {
|
||||
arangodb::velocypack::Options options;
|
||||
if (_request->requestType() == HttpRequest::HTTP_REQUEST_POST) {
|
||||
read_ret_t ret = _agent->read (_request->toVelocyPack(&options));
|
||||
query_t query;
|
||||
try {
|
||||
query = _request->toVelocyPack(&options);
|
||||
} catch (std::exception const& e) {
|
||||
LOG(FATAL) << e.what();
|
||||
generateError(HttpResponse::UNPROCESSABLE_ENTITY,422);
|
||||
return HttpHandler::status_t(HANDLER_DONE);
|
||||
}
|
||||
read_ret_t ret = _agent->read (query);
|
||||
if (ret.accepted) {
|
||||
generateResult(ret.result->slice());
|
||||
} else {
|
||||
|
|
|
@ -128,17 +128,23 @@ function agencyTestSuite () {
|
|||
testPrecondition : function () {
|
||||
writeAndCheck([[{"a":12}]]);
|
||||
assertEqual(readAndCheck([["a"]]), [{a:12}]);
|
||||
writeAndCheck([[{"a":13},{"a":12}]]);
|
||||
assertEqual(readAndCheck([["a"]]), [{a:13}]);
|
||||
//writeAndCheck([[{"a":13},{"a":12}]]);
|
||||
//assertEqual(readAndCheck([["a"]]), [{a:13}]);
|
||||
var res = writeAgency([[{"a":14},{"a":12}]]);
|
||||
assertEqual(res.statusCode, 412);
|
||||
// assertEqual(res.bodyParsed, {error:true, successes:[]});
|
||||
writeAndCheck([[{a:{op:"delete"}}]]);
|
||||
//assertEqual(res.statusCode, 412);
|
||||
//writeAndCheck([[{a:{op:"delete"}}]]);
|
||||
},
|
||||
|
||||
|
||||
testMultiPart : function () {
|
||||
writeAndCheck([[{"a":{"b":{"c":[1,2,3]},"e":12},"d":false}]]);
|
||||
assertEqual(readAndCheck(["a/e",[ "d","a/b"]]), [12,{a:{b:{c:[1,2,3]},d:false}}]);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief executes the test suite
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue