# HG changeset patch # User Sebastien Jodogne # Date 1560518494 -7200 # Node ID fd257a30e4feb923cbbebec6df6a76f2473d76f6 # Parent 0b48e7c96f30c188b3a08601169649fe73fa9c41 cont diff -r 0b48e7c96f30 -r fd257a30e4fe Plugin/DicomWebClient.cpp --- a/Plugin/DicomWebClient.cpp Fri Jun 14 10:11:31 2019 +0200 +++ b/Plugin/DicomWebClient.cpp Fri Jun 14 15:21:34 2019 +0200 @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -366,9 +367,25 @@ std::string target; target.reserve(source.size()); + size_t prefix = 0; + + if (boost::starts_with(source, "https://")) + { + prefix = 8; + } + else if (boost::starts_with(source, "http://")) + { + prefix = 7; + } + + for (size_t i = 0; i < prefix; i++) + { + target.push_back(source[i]); + } + bool isLastSlash = false; - for (size_t i = 0; i < source.size(); i++) + for (size_t i = prefix; i < source.size(); i++) { if (source[i] == '/') { @@ -439,28 +456,10 @@ { client.AddHeader(it->first, it->second); } - - std::map answerHeaders; - - { - Json::Value answer; - client.Execute(answerHeaders, answer); - - std::cout << answer.toStyledString() << std::endl; - } - - - - - - - - OrthancPlugins::MemoryBuffer answerBody; - - - OrthancPlugins::CallServer(answerBody, answerHeaders, server, OrthancPluginHttpMethod_Get, server.GetHttpHeaders(), uri, ""); + std::string answer; + client.Execute(answerHeaders, answer); std::string contentType = "application/octet-stream"; @@ -484,9 +483,8 @@ } } - OrthancPluginAnswerBuffer(context, output, - reinterpret_cast(answerBody.GetData()), - answerBody.GetSize(), contentType.c_str()); + OrthancPluginAnswerBuffer(context, output, answer.empty() ? NULL : answer.c_str(), + answer.size(), contentType.c_str()); }