Mercurial > hg > orthanc-dicomweb
changeset 301:fd257a30e4fe refactoring
cont
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 14 Jun 2019 15:21:34 +0200 |
parents | 0b48e7c96f30 |
children | ebd8a1cd97da |
files | Plugin/DicomWebClient.cpp |
diffstat | 1 files changed, 22 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- 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 <list> #include <set> #include <boost/lexical_cast.hpp> +#include <boost/algorithm/string/predicate.hpp> #include <Core/ChunkedBuffer.h> #include <Core/Toolbox.h> @@ -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<std::string, std::string> 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<const char*>(answerBody.GetData()), - answerBody.GetSize(), contentType.c_str()); + OrthancPluginAnswerBuffer(context, output, answer.empty() ? NULL : answer.c_str(), + answer.size(), contentType.c_str()); }