Commit fb101b93 by Amir Aharon

1.5.3 fix GetContent

parent cbac5752
...@@ -3,7 +3,7 @@ project(Microservice) ...@@ -3,7 +3,7 @@ project(Microservice)
# version stuff # version stuff
set (Microservice_VERSION_MAJOR 1) set (Microservice_VERSION_MAJOR 1)
set (Microservice_VERSION_MINOR 5) set (Microservice_VERSION_MINOR 5)
set (Microservice_VERSION_PATCH 2) set (Microservice_VERSION_PATCH 3)
set(Microservice_VERSION_STRING ${Microservice_VERSION_MAJOR}.${Microservice_VERSION_MINOR}.${Microservice_VERSION_PATCH}) set(Microservice_VERSION_STRING ${Microservice_VERSION_MAJOR}.${Microservice_VERSION_MINOR}.${Microservice_VERSION_PATCH})
# type build flags # type build flags
......
## C++ Microservice Framework ## C++ Microservice Framework
* to create microservice docker run script/build_microservice_docker.sh [version] * to create microservice docker run script/build_microservice_docker.sh [version]
## VERSIONS: ## VERSIONS:
# 1.5.3
- fix for IRequest->GetContent() in Evpp
# 1.5.2 # 1.5.2
- Fix for sigegv - Fix for sigegv
- testing http client performance - testing http client performance
......
...@@ -59,6 +59,7 @@ class Microservice_IRequestRestEvppImpl: public nsMicroservice_Iface::IRequest { ...@@ -59,6 +59,7 @@ class Microservice_IRequestRestEvppImpl: public nsMicroservice_Iface::IRequest {
public: public:
Microservice_IRequestRestEvppImpl(EvppConnParams connParams): connParams_(connParams) { Microservice_IRequestRestEvppImpl(EvppConnParams connParams): connParams_(connParams) {
queryString_ = ParseQueryString(); queryString_ = ParseQueryString();
body_ = connParams_.ctx_->body().ToString();
} }
const char *ParseQueryString() { const char *ParseQueryString() {
...@@ -82,10 +83,16 @@ public: ...@@ -82,10 +83,16 @@ public:
return connParams_.ctx_->uri().c_str(); return connParams_.ctx_->uri().c_str();
} }
/**
* @brief Get the Content object
* note that the body is a reference to a reusable buffer
* so we need to take into account the actual size
* @return const char*
*/
const char *GetContent() override { const char *GetContent() override {
// if (p_restMsg_) // if (p_restMsg_)
// return p_restMsg_->content()->c_str(); // return p_restMsg_->content()->c_str();
return connParams_.ctx_->body().data(); return body_.size() ? body_.c_str() : nullptr;
} }
void Reset() override { void Reset() override {
...@@ -98,6 +105,7 @@ public: ...@@ -98,6 +105,7 @@ public:
private: private:
EvppConnParams connParams_; EvppConnParams connParams_;
const char* queryString_; const char* queryString_;
std::string body_;
char buff_[nsMicroservice_Constants::MAX_URI_LENGTH]; char buff_[nsMicroservice_Constants::MAX_URI_LENGTH];
}; };
......
...@@ -82,15 +82,16 @@ public: ...@@ -82,15 +82,16 @@ public:
// CreateSync(pc_reqCtx); // CreateSync(pc_reqCtx);
} }
else { else {
MsgArchiverJsonLohmann archiverJsonLohmann; // MsgArchiverJsonLohmann archiverJsonLohmann;
nlohmann::json outMsg; // nlohmann::json outMsg;
if (this->ReadObjectFromRequest<>(pc_reqCtx,archiverJsonLohmann,outMsg)) // if (this->ReadObjectFromRequest<>(pc_reqCtx,archiverJsonLohmann,outMsg))
this->WriteObjectToResponse<>(pc_reqCtx,archiverJsonLohmann,outMsg); // this->WriteObjectToResponse<>(pc_reqCtx,archiverJsonLohmann,outMsg);
// rapidjson::Document rpj_Doc; // else
// if (this->ReadObjectFromRequest(pc_reqCtx,rpj_Doc) ) rapidjson::Document rpj_Doc;
// this->WriteObjectToResponse(pc_reqCtx,rpj_Doc); if (this->ReadObjectFromRequest(pc_reqCtx,rpj_Doc) )
// else this->WriteObjectToResponse(pc_reqCtx,rpj_Doc);
// this->SendErrorResp(pc_reqCtx,"Error in parsing json"); else
this->SendErrorResp(pc_reqCtx,"Error in parsing json");
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment