mirror of https://gitee.com/bigwinds/arangodb
RestQueryHandler uses the first VelocyPack parsed user input
This commit is contained in:
parent
2ff01110f7
commit
34e4d461d0
|
@ -224,13 +224,21 @@ bool RestQueryCacheHandler::replaceProperties () {
|
||||||
"expecting PUT /_api/query-cache/properties");
|
"expecting PUT /_api/query-cache/properties");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool validBody = true;
|
||||||
|
VPackBuilder parsedBody = parseVelocyPackBody(validBody);
|
||||||
|
|
||||||
std::unique_ptr<TRI_json_t> body(parseJsonBody());
|
if (! validBody) {
|
||||||
|
|
||||||
if (body == nullptr) {
|
|
||||||
// error message generated in parseJsonBody
|
// error message generated in parseJsonBody
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
VPackSlice body = parsedBody.slice();
|
||||||
|
|
||||||
|
if (! body.isObject()) {
|
||||||
|
generateError(HttpResponse::BAD,
|
||||||
|
TRI_ERROR_HTTP_BAD_PARAMETER,
|
||||||
|
"expecting a JSON-Object body");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
auto queryCache = triagens::aql::QueryCache::instance();
|
auto queryCache = triagens::aql::QueryCache::instance();
|
||||||
|
|
||||||
|
@ -238,16 +246,17 @@ bool RestQueryCacheHandler::replaceProperties () {
|
||||||
std::pair<std::string, size_t> cacheProperties;
|
std::pair<std::string, size_t> cacheProperties;
|
||||||
queryCache->properties(cacheProperties);
|
queryCache->properties(cacheProperties);
|
||||||
|
|
||||||
auto attribute = static_cast<TRI_json_t const*>(TRI_LookupObjectJson(body.get(), "mode"));
|
VPackSlice attribute = body.get("mode");
|
||||||
|
if (attribute.isString()) {
|
||||||
if (TRI_IsStringJson(attribute)) {
|
VPackValueLength len;
|
||||||
cacheProperties.first = std::string(attribute->_value._string.data, attribute->_value._string.length - 1);
|
char const* st = attribute.getString(len);
|
||||||
|
cacheProperties.first = std::string(st, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
attribute = static_cast<TRI_json_t const*>(TRI_LookupObjectJson(body.get(), "maxResults"));
|
attribute = body.get("maxResults");
|
||||||
|
|
||||||
if (TRI_IsNumberJson(attribute)) {
|
if (attribute.isNumber()) {
|
||||||
cacheProperties.second = static_cast<size_t>(attribute->_value._number);
|
cacheProperties.second = static_cast<size_t>(attribute.getUInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
queryCache->setProperties(cacheProperties);
|
queryCache->setProperties(cacheProperties);
|
||||||
|
|
Loading…
Reference in New Issue