mirror of https://gitee.com/bigwinds/arangodb
fix some errors -- http tests failing in cluster
This commit is contained in:
parent
29a87ef109
commit
c59a553723
|
@ -30,7 +30,7 @@
|
|||
#include "Cluster/ClusterInfo.h"
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "Dispatcher/DispatcherThread.h"
|
||||
#include "Rest/FakeRequest.h"
|
||||
//#include "Rest/FakeRequest.h"
|
||||
#include "SimpleHttpClient/ConnectionManager.h"
|
||||
#include "SimpleHttpClient/SimpleHttpClient.h"
|
||||
#include "Utils/Transaction.h"
|
||||
|
@ -1276,11 +1276,11 @@ size_t ClusterComm::performSingleRequest(
|
|||
// Add correct recognition of content type later.
|
||||
basics::StringBuffer& buffer = req.result.result->getBody();
|
||||
|
||||
auto answer = new FakeRequest(type, buffer.c_str(),
|
||||
static_cast<int64_t>(buffer.length()));
|
||||
answer->setHeaders(req.result.result->getHeaderFields());
|
||||
// auto answer = new FakeRequest(type, buffer.c_str(),
|
||||
// static_cast<int64_t>(buffer.length()));
|
||||
// answer->setHeaders(req.result.result->getHeaderFields());
|
||||
|
||||
auto answer = new HttpRequest::createFakeRequest(
|
||||
auto answer = HttpRequest::createFakeRequest(
|
||||
type, buffer.c_str(), static_cast<int64_t>(buffer.length()),
|
||||
req.result.result->getHeaderFields());
|
||||
|
||||
|
|
|
@ -208,7 +208,6 @@ add_library(${LIB_ARANGO} STATIC
|
|||
Random/RandomFeature.cpp
|
||||
Random/RandomGenerator.cpp
|
||||
Random/UniformCharacter.cpp
|
||||
Rest/FakeRequest.cpp
|
||||
Rest/GeneralRequest.cpp
|
||||
Rest/GeneralResponse.cpp
|
||||
Rest/VppRequest.cpp
|
||||
|
|
|
@ -57,6 +57,47 @@ class FakeRequest : public GeneralRequest {
|
|||
//_headers = headers; // this is from the base class
|
||||
}
|
||||
|
||||
// get value from headers map. The key must be lowercase.
|
||||
std::string const& header(std::string const& key) const override {
|
||||
throw std::logic_error("not implemented");
|
||||
return "";
|
||||
}
|
||||
std::string const& header(std::string const& key,
|
||||
bool& found) const override {
|
||||
throw std::logic_error("not implemented");
|
||||
return "";
|
||||
}
|
||||
|
||||
// return headers map
|
||||
virtual std::unordered_map<std::string, std::string> const& headers()
|
||||
const override {
|
||||
throw std::logic_error("not implemented");
|
||||
return std::unordered_map<std::string, std::string>();
|
||||
}
|
||||
|
||||
virtual std::string const& value(std::string const& key) const override {
|
||||
throw std::logic_error("not implemented");
|
||||
return "";
|
||||
}
|
||||
virtual std::string const& value(std::string const& key,
|
||||
bool& found) const override {
|
||||
throw std::logic_error("not implemented");
|
||||
return "";
|
||||
}
|
||||
virtual std::unordered_map<std::string, std::string> values() const override {
|
||||
throw std::logic_error("not implemented");
|
||||
return std::unordered_map<std::string, std::string>();
|
||||
}
|
||||
virtual std::unordered_map<std::string, std::vector<std::string>>
|
||||
arrayValues() const override {
|
||||
throw std::logic_error("not implemented");
|
||||
return std::unordered_map<std::string, std::vector<std::string>>();
|
||||
}
|
||||
virtual void setArrayValue(std::string const& key,
|
||||
std::string const& value) override {
|
||||
throw std::logic_error("not implemented");
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::string> _cookies;
|
||||
ContentType _contentType;
|
||||
|
|
|
@ -170,8 +170,6 @@ class GeneralRequest {
|
|||
virtual std::unordered_map<std::string, std::string> values() const = 0;
|
||||
virtual std::unordered_map<std::string, std::vector<std::string>>
|
||||
arrayValues() const = 0;
|
||||
virtual void setArrayValue(std::string const& key,
|
||||
std::string const& value) = 0;
|
||||
|
||||
bool velocyPackResponse() const;
|
||||
|
||||
|
|
|
@ -411,6 +411,11 @@ void HttpRequest::parseHeader(size_t length) {
|
|||
}
|
||||
}
|
||||
|
||||
void HttpRequest::setArrayValue(std::string const&& key,
|
||||
std::string const&& value) {
|
||||
_arrayValues[key].emplace_back(value);
|
||||
}
|
||||
|
||||
void HttpRequest::setArrayValue(char* key, size_t length, char const* value) {
|
||||
_arrayValues[std::string(key, length)].emplace_back(value);
|
||||
}
|
||||
|
|
|
@ -97,7 +97,6 @@ class HttpRequest : public GeneralRequest {
|
|||
const override {
|
||||
return _arrayValues;
|
||||
}
|
||||
void setArrayValue(std::string const& key, std::string const& value) override;
|
||||
|
||||
std::string const& cookieValue(std::string const& key) const;
|
||||
std::string const& cookieValue(std::string const& key, bool& found) const;
|
||||
|
@ -121,9 +120,17 @@ class HttpRequest : public GeneralRequest {
|
|||
/// @brief sets a key-only header
|
||||
void setHeader(char const* key, size_t keyLength);
|
||||
|
||||
static HttpRequest* createFakeRequest(
|
||||
ContentType contentType, char const* body, int64_t contentLength,
|
||||
std::unordered_map<std::string, std::string> headers) {
|
||||
return new HttpRequest(contentType, body, contentLength,
|
||||
std::move(headers));
|
||||
}
|
||||
|
||||
protected:
|
||||
void setValue(char const* key, char const* value);
|
||||
void setArrayValue(char* key, size_t length, char const* value);
|
||||
void setArrayValue(std::string const&& key, std::string const&& value);
|
||||
|
||||
private:
|
||||
void parseHeader(size_t length);
|
||||
|
@ -148,13 +155,6 @@ class HttpRequest : public GeneralRequest {
|
|||
_headers; // gets set by httpRequest: parseHeaders -> setHeaders
|
||||
std::unordered_map<std::string, std::string> _values;
|
||||
std::unordered_map<std::string, std::vector<std::string>> _arrayValues;
|
||||
|
||||
private:
|
||||
static HttpRequest createFakeRequest(
|
||||
ContentType contentType, char const* body, int64_t contentLength,
|
||||
std::unordered_map<std::string, std::string>&& headers) {
|
||||
return HttpRequest(contentType, body, contentLength, std::move(headers));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
using namespace arangodb;
|
||||
using namespace arangodb::basics;
|
||||
|
||||
std::string const VppRequest::_bla = "";
|
||||
std::unordered_map<std::string, std::string> VppRequest::_blam =
|
||||
std::unordered_map<std::string, std::string>();
|
||||
|
||||
VppRequest::VppRequest(ConnectionInfo const& connectionInfo,
|
||||
VPackBuffer<uint8_t>&& header, size_t length)
|
||||
: GeneralRequest(connectionInfo),
|
||||
|
|
|
@ -57,6 +57,10 @@ class VppRequest : public GeneralRequest {
|
|||
VppRequest(ConnectionInfo const& connectionInfo,
|
||||
VPackBuffer<uint8_t>&& header, size_t length);
|
||||
|
||||
private:
|
||||
static std::string const _bla;
|
||||
static std::unordered_map<std::string, std::string> _blam;
|
||||
|
||||
public:
|
||||
~VppRequest() {}
|
||||
|
||||
|
@ -66,9 +70,47 @@ class VppRequest : public GeneralRequest {
|
|||
void setPayload(VPackBuffer<uint8_t>&& payload) { _payload = payload; }
|
||||
|
||||
std::unordered_map<std::string, std::string> const& headers() const override {
|
||||
throw std::logic_error("this needs to be implmented");
|
||||
throw std::logic_error("not implemented");
|
||||
return _blam;
|
||||
}
|
||||
|
||||
void setHeaders(std::unordered_map<std::string, std::string> const& headers) {
|
||||
throw std::logic_error("the base class has no headers anymore.");
|
||||
// add a new ctor to HttpRequest that is cheaper in order to wrap simple
|
||||
// http request
|
||||
// and remove The Fake request
|
||||
//_headers = headers; // this is from the base class
|
||||
}
|
||||
|
||||
// get value from headers map. The key must be lowercase.
|
||||
std::string const& header(std::string const& key) const override {
|
||||
throw std::logic_error("not implemented");
|
||||
return _bla;
|
||||
}
|
||||
std::string const& header(std::string const& key,
|
||||
bool& found) const override {
|
||||
throw std::logic_error("not implemented");
|
||||
return _bla;
|
||||
}
|
||||
|
||||
virtual std::string const& value(std::string const& key) const override {
|
||||
throw std::logic_error("not implemented");
|
||||
return _bla;
|
||||
}
|
||||
virtual std::string const& value(std::string const& key,
|
||||
bool& found) const override {
|
||||
throw std::logic_error("not implemented");
|
||||
return _bla;
|
||||
}
|
||||
virtual std::unordered_map<std::string, std::string> values() const override {
|
||||
throw std::logic_error("not implemented");
|
||||
return std::unordered_map<std::string, std::string>();
|
||||
}
|
||||
virtual std::unordered_map<std::string, std::vector<std::string>>
|
||||
arrayValues() const override {
|
||||
throw std::logic_error("not implemented");
|
||||
return std::unordered_map<std::string, std::vector<std::string>>();
|
||||
}
|
||||
|
||||
private:
|
||||
void parseHeader(); // converts _header(vpack) to
|
||||
|
|
Loading…
Reference in New Issue