# HG changeset patch # User Sebastien Jodogne # Date 1560850638 -7200 # Node ID 6503ab9489ba24dce5c62b3cb96d0ac3e80a0947 # Parent caa526bb65cce795a19b34a6d498b573ca5a5a6e fix diff -r caa526bb65cc -r 6503ab9489ba Plugins/Samples/Common/OrthancPluginCppWrapper.cpp --- a/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Tue Jun 18 09:10:27 2019 +0200 +++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Tue Jun 18 11:37:18 2019 +0200 @@ -2350,6 +2350,10 @@ body_(body), done_(false) { + if (body_.empty()) + { + done_ = true; + } } virtual bool ReadNextChunk(std::string& chunk) @@ -2477,21 +2481,25 @@ { HeadersWrapper h(headers_); - // Automatically set the "Transfer-Encoding" header if absent - bool found = false; - - for (HttpHeaders::const_iterator it = headers_.begin(); it != headers_.end(); ++it) + if (method_ == OrthancPluginHttpMethod_Post || + method_ == OrthancPluginHttpMethod_Put) { - if (boost::iequals(it->first, "Transfer-Encoding")) + // Automatically set the "Transfer-Encoding" header if absent + bool found = false; + + for (HttpHeaders::const_iterator it = headers_.begin(); it != headers_.end(); ++it) { - found = true; - break; + if (boost::iequals(it->first, "Transfer-Encoding")) + { + found = true; + break; + } } - } - - if (!found) - { - h.AddStaticString("Transfer-Encoding", "chunked"); + + if (!found) + { + h.AddStaticString("Transfer-Encoding", "chunked"); + } } RequestBodyWrapper request(body); @@ -2657,6 +2665,14 @@ } } + + void HttpClient::Execute() + { + HttpHeaders answerHeaders; + std::string body; + Execute(answerHeaders, body); + } + #endif /* HAS_ORTHANC_PLUGIN_HTTP_CLIENT == 1 */ diff -r caa526bb65cc -r 6503ab9489ba Plugins/Samples/Common/OrthancPluginCppWrapper.h --- a/Plugins/Samples/Common/OrthancPluginCppWrapper.h Tue Jun 18 09:10:27 2019 +0200 +++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.h Tue Jun 18 11:37:18 2019 +0200 @@ -929,6 +929,8 @@ void Execute(HttpHeaders& answerHeaders /* out */, Json::Value& answerBody /* out */); + + void Execute(); }; #endif