Mercurial > hg > orthanc-dicomweb
changeset 281:b458aa0321a2
testing multipart server
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 07 Jun 2019 11:29:12 +0200 |
parents | bff26b6f69f5 |
children | 266556663ae6 |
files | Plugin/Plugin.cpp |
diffstat | 1 files changed, 60 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugin/Plugin.cpp Thu Jun 06 16:49:12 2019 +0200 +++ b/Plugin/Plugin.cpp Fri Jun 07 11:29:12 2019 +0200 @@ -174,6 +174,65 @@ #include <boost/filesystem.hpp> #include <Core/SystemToolbox.h> + +class StowServer : public OrthancPlugins::MultipartRestCallback +{ +private: + class Handler : public IHandler + { + private: + unsigned int count_; + + public: + Handler(unsigned int count) : + count_(count) + { + printf("new handler: %d\n", count_); + } + + virtual OrthancPluginErrorCode AddPart(const std::string& contentType, + const std::map<std::string, std::string>& headers, + const void* data, + size_t size) + { + printf("%d - part received: %d\n", count_, size); + throw Orthanc::OrthancException(Orthanc::ErrorCode_CanceledJob); + return OrthancPluginErrorCode_Success; + } + + virtual OrthancPluginErrorCode Execute(OrthancPluginRestOutput* output) + { + printf("%d - execute\n", count_); + //throw Orthanc::OrthancException(Orthanc::ErrorCode_CanceledJob); + + std::string s = "ok"; + + OrthancPluginAnswerBuffer(OrthancPlugins::GetGlobalContext(), output, s.c_str(), s.size(), "text/plain"); + return OrthancPluginErrorCode_Success; + } + }; + + unsigned int count_; + +public: + StowServer() : count_(0) + { + } + + virtual IHandler* CreateHandler(OrthancPluginHttpMethod method, + const std::string& url, + const std::string& contentType, + const std::vector<std::string>& groups, + const std::map<std::string, std::string>& headers) + { + return new Handler(count_++); + } +}; + + +static StowServer stowServer_; + + class StowClientBody : public OrthancPlugins::HttpClient::IRequestBody { private: @@ -308,6 +367,7 @@ OrthancPlugins::Configuration::Initialize(); //OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback); // TODO => REMOVE + //stowServer_.Register("/toto"); // TODO => REMOVE // Initialize GDCM OrthancPlugins::GdcmParsedDicomFile::Initialize();