# HG changeset patch # User Sebastien Jodogne # Date 1559832161 -7200 # Node ID 2f82ef41bf5a7e530e1a8876aca5f2d4abc01fb0 # Parent 2cd0369a156fbafc8e97131dfdca9559fa4f45c1 fix diff -r 2cd0369a156f -r 2f82ef41bf5a Plugins/Samples/Common/OrthancPluginCppWrapper.cpp --- a/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Thu Jun 06 16:12:55 2019 +0200 +++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Thu Jun 06 16:42:41 2019 +0200 @@ -33,6 +33,7 @@ #include "OrthancPluginCppWrapper.h" +#include #include #include @@ -2262,6 +2263,13 @@ } } + void AddStaticString(const char* key, + const char* value) + { + headersKeys_.push_back(key); + headersValues_.push_back(value); + } + uint32_t GetCount() const { return headersKeys_.size(); @@ -2405,18 +2413,23 @@ IAnswer& answer, IRequestBody& body) const { - std::auto_ptr h; + HeadersWrapper h(headers_); // Automatically set the "Transfer-Encoding" header if absent - if (headers_.find("Transfer-Encoding") == headers_.end()) + bool found = false; + + for (HttpHeaders::const_iterator it = headers_.begin(); it != headers_.end(); ++it) { - HttpHeaders tmp = headers_; - tmp["Transfer-Encoding"] = "chunked"; - h.reset(new HeadersWrapper(tmp)); + if (boost::iequals(it->first, "Transfer-Encoding")) + { + found = true; + break; + } } - else + + if (!found) { - h.reset(new HeadersWrapper(headers_)); + h.AddStaticString("Transfer-Encoding", "chunked"); } RequestBodyWrapper request(body); @@ -2429,9 +2442,9 @@ &httpStatus, method_, url_.c_str(), - h->GetCount(), - h->GetKeys(), - h->GetValues(), + h.GetCount(), + h.GetKeys(), + h.GetValues(), &request, RequestBodyWrapper::IsDone, RequestBodyWrapper::GetChunkData,