mirror of https://gitee.com/bigwinds/arangodb
Removed TRI_json_t from V8 client connection
This commit is contained in:
parent
de588621bc
commit
c67c95eae4
|
@ -32,10 +32,9 @@
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "Basics/JsonHelper.h"
|
|
||||||
#include "Basics/StringUtils.h"
|
#include "Basics/StringUtils.h"
|
||||||
#include "Basics/json.h"
|
|
||||||
#include "Basics/tri-strings.h"
|
#include "Basics/tri-strings.h"
|
||||||
|
#include "Basics/VelocyPackHelper.h"
|
||||||
#include "Rest/HttpRequest.h"
|
#include "Rest/HttpRequest.h"
|
||||||
#include "Rest/HttpResponse.h"
|
#include "Rest/HttpResponse.h"
|
||||||
#include "SimpleHttpClient/GeneralClientConnection.h"
|
#include "SimpleHttpClient/GeneralClientConnection.h"
|
||||||
|
@ -107,28 +106,29 @@ V8ClientConnection::V8ClientConnection (Endpoint* endpoint,
|
||||||
_version = "arango";
|
_version = "arango";
|
||||||
_mode = "unknown mode";
|
_mode = "unknown mode";
|
||||||
|
|
||||||
// convert response body to json
|
try {
|
||||||
std::unique_ptr<TRI_json_t> json(TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, result->getBody().c_str()));
|
VPackOptions options;
|
||||||
|
options.checkAttributeUniqueness = true;
|
||||||
if (json != nullptr) {
|
std::shared_ptr<VPackBuilder> parsedBody = result->getBodyVelocyPack(options);
|
||||||
// look up "server" value
|
VPackSlice const body = parsedBody->slice();
|
||||||
const string server = JsonHelper::getStringValue(json.get(), "server", "");
|
const string server = triagens::basics::VelocyPackHelper::getStringValue(body, "server", "");
|
||||||
|
|
||||||
// "server" value is a string and content is "arango"
|
// "server" value is a string and content is "arango"
|
||||||
if (server == "arango") {
|
if (server == "arango") {
|
||||||
// look up "version" value
|
// look up "version" value
|
||||||
_version = JsonHelper::getStringValue(json.get(), "version", "");
|
_version = triagens::basics::VelocyPackHelper::getStringValue(body, "version", "");
|
||||||
auto const* details = TRI_LookupObjectJson(json.get(), "details");
|
VPackSlice const details = body.get("details");
|
||||||
|
if (details.isObject()) {
|
||||||
if (TRI_IsObjectJson(details)) {
|
VPackSlice const mode = details.get("mode");
|
||||||
auto const* mode = TRI_LookupObjectJson(details, "mode");
|
if (mode.isString()) {
|
||||||
|
_mode = mode.copyString();
|
||||||
if (TRI_IsStringJson(mode)) {
|
|
||||||
_mode = std::string(mode->_value._string.data, mode->_value._string.length - 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (...) {
|
||||||
|
// Ignore all parse errors
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// initial request for /_api/version returned some non-HTTP 200 response.
|
// initial request for /_api/version returned some non-HTTP 200 response.
|
||||||
|
|
Loading…
Reference in New Issue