diff --git a/arangod/Agency/Constituent.cpp b/arangod/Agency/Constituent.cpp index bf9d5a377b..c6e584422e 100644 --- a/arangod/Agency/Constituent.cpp +++ b/arangod/Agency/Constituent.cpp @@ -113,7 +113,7 @@ void Constituent::termNoLock(term_t t, std::string const& votedFor) { if (tmp != t || tmpVotedFor != votedFor) { LOG_TOPIC(INFO, Logger::AGENCY) << _id << ": changing term or votedFor, " - << "current role:" << roleStr[_role] << " term " << t << " votedFor: " + << "current role: " << roleStr[_role] << " term " << t << " votedFor: " << votedFor; Builder body; diff --git a/arangod/Cluster/ClusterComm.h b/arangod/Cluster/ClusterComm.h index a852eec081..382b7c00fa 100644 --- a/arangod/Cluster/ClusterComm.h +++ b/arangod/Cluster/ClusterComm.h @@ -270,13 +270,12 @@ struct ClusterCommResult { dynamic_cast(response.get())->body().c_str(), dynamic_cast(response.get())->body().length(), std::unordered_map()); - auto headers = response->headers(); + auto const& headers = response->headers(); auto errorCodes = headers.find(StaticStrings::ErrorCodes); if (errorCodes != headers.end()) { request->setHeader(StaticStrings::ErrorCodes, errorCodes->second); } - request->setHeader("x-arango-response-code", - GeneralResponse::responseString(answer_code)); + request->setHeader(StaticStrings::ResponseCode, GeneralResponse::responseString(answer_code)); answer.reset(request); TRI_ASSERT(response != nullptr); result = std::make_shared( diff --git a/arangod/Cluster/ClusterMethods.cpp b/arangod/Cluster/ClusterMethods.cpp index 8313ca6380..e0578d6b4f 100644 --- a/arangod/Cluster/ClusterMethods.cpp +++ b/arangod/Cluster/ClusterMethods.cpp @@ -285,7 +285,7 @@ static void mergeResultsAllShards( static void extractErrorCodes(ClusterCommResult const& res, std::unordered_map& errorCounter, bool includeNotFound) { - auto resultHeaders = res.answer->headers(); + auto const& resultHeaders = res.answer->headers(); auto codes = resultHeaders.find(StaticStrings::ErrorCodes); if (codes != resultHeaders.end()) { auto parsedCodes = VPackParser::fromJson(codes->second); diff --git a/arangod/Cluster/RestClusterHandler.cpp b/arangod/Cluster/RestClusterHandler.cpp index 9238e8c825..f9a42c8c97 100644 --- a/arangod/Cluster/RestClusterHandler.cpp +++ b/arangod/Cluster/RestClusterHandler.cpp @@ -105,7 +105,7 @@ void RestClusterHandler::handleCommandEndpoints() { // endpoint value, and can tell the following two cases apart: // - endpoint value is not empty: there is a leader, and it is known // - endpoint value is empty: leadership challenge is ongoing, current leader is unknown - _response->setHeader(StaticStrings::LeaderEndpoint, ""); + _response->setHeaderNC(StaticStrings::LeaderEndpoint, ""); return; } diff --git a/arangod/GeneralServer/RestHandlerFactory.cpp b/arangod/GeneralServer/RestHandlerFactory.cpp index 16ac8cbff4..34916a1c0e 100644 --- a/arangod/GeneralServer/RestHandlerFactory.cpp +++ b/arangod/GeneralServer/RestHandlerFactory.cpp @@ -69,7 +69,7 @@ class MaintenanceHandler : public RestBaseHandler { } generateError(Result(TRI_ERROR_CLUSTER_NOT_LEADER)); // return the endpoint of the actual leader - _response->setHeader(StaticStrings::LeaderEndpoint, endpoint); + _response->setHeaderNC(StaticStrings::LeaderEndpoint, endpoint); break; } @@ -78,7 +78,7 @@ class MaintenanceHandler : public RestBaseHandler { // intentionally do not set "Location" header, but use a custom header that // clients can inspect. if they find an empty endpoint, it means that there // is an ongoing leadership challenge - _response->setHeader(StaticStrings::LeaderEndpoint, ""); + _response->setHeaderNC(StaticStrings::LeaderEndpoint, ""); break; } diff --git a/arangod/RestHandler/RestCollectionHandler.cpp b/arangod/RestHandler/RestCollectionHandler.cpp index 942a310480..6f05371833 100644 --- a/arangod/RestHandler/RestCollectionHandler.cpp +++ b/arangod/RestHandler/RestCollectionHandler.cpp @@ -203,7 +203,7 @@ void RestCollectionHandler::handleCommandGet() { } if (found.ok()) { generateOk(rest::ResponseCode::OK, builder); - _response->setHeader("location", _request->requestPath()); + _response->setHeaderNC(StaticStrings::Location, _request->requestPath()); } else { generateError(found); } @@ -400,7 +400,7 @@ void RestCollectionHandler::handleCommandPut() { generateError(found); } else if (res.ok()) { generateOk(rest::ResponseCode::OK, builder); - _response->setHeader("location", _request->requestPath()); + _response->setHeaderNC(StaticStrings::Location, _request->requestPath()); } else { generateError(res); } diff --git a/arangod/V8Server/v8-actions.cpp b/arangod/V8Server/v8-actions.cpp index 0717255ad1..ae1b2863d6 100644 --- a/arangod/V8Server/v8-actions.cpp +++ b/arangod/V8Server/v8-actions.cpp @@ -415,7 +415,7 @@ static v8::Handle RequestCppToV8(v8::Isolate* isolate, // copy header fields v8::Handle headerFields = v8::Object::New(isolate); - + // intentional copy, as we will modify the headers later auto headers = request->headers(); TRI_GET_GLOBAL_STRING(HeadersKey); @@ -526,7 +526,7 @@ static v8::Handle RequestCppToV8(v8::Isolate* isolate, TRI_GET_GLOBAL_STRING(ParametersKey); req->ForceSet(ParametersKey, valuesObject); - // copy cookie -- only for http protocl + // copy cookie -- only for http protocol if (request->transportType() == Endpoint::TransportType::HTTP) { // FIXME v8::Handle cookiesObject = v8::Object::New(isolate); @@ -591,8 +591,8 @@ static void ResponseV8ToCpp(v8::Isolate* isolate, TRI_v8_global_t const* v8g, break; case Endpoint::TransportType::VST: - response->setHeader(arangodb::StaticStrings::ContentTypeHeader, - contentType); + response->setHeaderNC(arangodb::StaticStrings::ContentTypeHeader, + contentType); break; default: diff --git a/arangod/VocBase/Methods/Transactions.h b/arangod/VocBase/Methods/Transactions.h index 06d0443efa..be722e7922 100644 --- a/arangod/VocBase/Methods/Transactions.h +++ b/arangod/VocBase/Methods/Transactions.h @@ -1,5 +1,5 @@ #ifndef ARANGOD_VOCBASE_METHODS_TRANSACTIONS_HANDLER_H -#define ARANGOD_VOCBASW_METHODS_TRANSACTIONS_HANDLER_H 1 +#define ARANGOD_VOCBASE_METHODS_TRANSACTIONS_HANDLER_H 1 #include "Basics/ReadWriteLock.h" #include "Basics/Result.h" diff --git a/lib/Basics/StaticStrings.cpp b/lib/Basics/StaticStrings.cpp index 9880735a60..08de6c01ba 100644 --- a/lib/Basics/StaticStrings.cpp +++ b/lib/Basics/StaticStrings.cpp @@ -117,6 +117,7 @@ std::string const StaticStrings::Location("location"); std::string const StaticStrings::MultiPartContentType("multipart/form-data"); std::string const StaticStrings::NoSniff("nosniff"); std::string const StaticStrings::Origin("origin"); +std::string const StaticStrings::ResponseCode("x-arango-response-code"); std::string const StaticStrings::Queue("x-arango-queue"); std::string const StaticStrings::Server("server"); std::string const StaticStrings::StartThread("x-arango-start-thread"); diff --git a/lib/Basics/StaticStrings.h b/lib/Basics/StaticStrings.h index 8c0f2741f4..083d8d43d6 100644 --- a/lib/Basics/StaticStrings.h +++ b/lib/Basics/StaticStrings.h @@ -112,6 +112,7 @@ class StaticStrings { static std::string const MultiPartContentType; static std::string const NoSniff; static std::string const Origin; + static std::string const ResponseCode; static std::string const Queue; static std::string const Server; static std::string const StartThread; diff --git a/lib/Rest/GeneralResponse.cpp b/lib/Rest/GeneralResponse.cpp index 9b77133be8..a957be0e48 100644 --- a/lib/Rest/GeneralResponse.cpp +++ b/lib/Rest/GeneralResponse.cpp @@ -433,7 +433,6 @@ rest::ResponseCode GeneralResponse::responseCode(int code) { GeneralResponse::GeneralResponse(ResponseCode responseCode) : _responseCode(responseCode), - _headers(), _contentType(ContentType::UNSET), _connectionType(ConnectionType::C_NONE), _options(velocypack::Options::Defaults), diff --git a/lib/Rest/GeneralResponse.h b/lib/Rest/GeneralResponse.h index 12692f37bc..84f89afb32 100644 --- a/lib/Rest/GeneralResponse.h +++ b/lib/Rest/GeneralResponse.h @@ -104,7 +104,7 @@ class GeneralResponse { _headers = std::move(headers); } - std::unordered_map headers() const { + std::unordered_map const& headers() const { return _headers; } @@ -155,10 +155,10 @@ class GeneralResponse { bool resolveExternals = true) = 0; virtual int reservePayload(std::size_t size) { return TRI_ERROR_NO_ERROR; } - bool generateBody() const { return _generateBody; }; // used for head + bool generateBody() const { return _generateBody; } // used for head virtual bool setGenerateBody(bool) { return _generateBody; - }; // used for head + } // used for head // resonses void setOptions(VPackOptions options) { _options = std::move(options); }; diff --git a/lib/Rest/HttpRequest.h b/lib/Rest/HttpRequest.h index b17631e837..55c01d7004 100644 --- a/lib/Rest/HttpRequest.h +++ b/lib/Rest/HttpRequest.h @@ -34,7 +34,6 @@ class RestBatchHandler; namespace rest { class GeneralCommTask; class HttpCommTask; -class HttpsCommTask; } namespace velocypack { @@ -44,7 +43,6 @@ struct Options; class HttpRequest final : public GeneralRequest { friend class rest::HttpCommTask; - friend class rest::HttpsCommTask; friend class rest::GeneralCommTask; friend class RestBatchHandler; // TODO must be removed diff --git a/lib/Rest/HttpResponse.cpp b/lib/Rest/HttpResponse.cpp index d7462f2dd1..08b018ca11 100644 --- a/lib/Rest/HttpResponse.cpp +++ b/lib/Rest/HttpResponse.cpp @@ -223,7 +223,7 @@ void HttpResponse::writeHeader(StringBuffer* output) { // add "Server" response header if (!seenServerHeader && !HIDE_PRODUCT_HEADER) { - output->appendText("Server: ArangoDB\r\n"); + output->appendText(TRI_CHAR_LENGTH_PAIR("Server: ArangoDB\r\n")); } // add "Connection" response header diff --git a/lib/Rest/VstRequest.cpp b/lib/Rest/VstRequest.cpp index 3b0ccb228a..a70bc6c9e2 100644 --- a/lib/Rest/VstRequest.cpp +++ b/lib/Rest/VstRequest.cpp @@ -63,7 +63,6 @@ VstRequest::VstRequest(ConnectionInfo const& connectionInfo, VstInputMessage&& message, uint64_t messageId, bool isFake) : GeneralRequest(connectionInfo), _message(std::move(message)), - _headers(nullptr), _messageId(messageId) { _protocol = "vst"; _contentType = ContentType::VPACK; diff --git a/lib/SimpleHttpClient/SimpleHttpCommunicatorResult.h b/lib/SimpleHttpClient/SimpleHttpCommunicatorResult.h index 178e2d3934..3f335b7747 100644 --- a/lib/SimpleHttpClient/SimpleHttpCommunicatorResult.h +++ b/lib/SimpleHttpClient/SimpleHttpCommunicatorResult.h @@ -72,7 +72,7 @@ class SimpleHttpCommunicatorResult: public SimpleHttpResult { throw std::runtime_error(message); } virtual std::string getHeaderField(std::string const& header, bool& found) const override { - auto headers = _response->headers(); + auto const& headers = _response->headers(); auto it = headers.find(header); if (it == headers.end()) { return "";