Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi/OrthancRestApi.cpp @ 3695:898903022836 storage-commitment
integration mainline->storage-commitment
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 26 Feb 2020 10:39:55 +0100 |
parents | e85bfba2d307 |
children | 2a170a8f1faf |
comparison
equal
deleted
inserted
replaced
3681:9dac85e807c2 | 3695:898903022836 |
---|---|
32 | 32 |
33 | 33 |
34 #include "../PrecompiledHeadersServer.h" | 34 #include "../PrecompiledHeadersServer.h" |
35 #include "OrthancRestApi.h" | 35 #include "OrthancRestApi.h" |
36 | 36 |
37 #include "../../Core/Compression/GzipCompressor.h" | |
37 #include "../../Core/Logging.h" | 38 #include "../../Core/Logging.h" |
38 #include "../../Core/MetricsRegistry.h" | 39 #include "../../Core/MetricsRegistry.h" |
39 #include "../../Core/SerializationToolbox.h" | 40 #include "../../Core/SerializationToolbox.h" |
40 #include "../ServerContext.h" | 41 #include "../ServerContext.h" |
42 | |
43 #include <boost/algorithm/string/predicate.hpp> | |
41 | 44 |
42 namespace Orthanc | 45 namespace Orthanc |
43 { | 46 { |
44 static void SetupResourceAnswer(Json::Value& result, | 47 static void SetupResourceAnswer(Json::Value& result, |
45 const std::string& publicId, | 48 const std::string& publicId, |
116 { | 119 { |
117 throw OrthancException(ErrorCode_BadFileFormat, | 120 throw OrthancException(ErrorCode_BadFileFormat, |
118 "Received an empty DICOM file"); | 121 "Received an empty DICOM file"); |
119 } | 122 } |
120 | 123 |
121 // TODO Remove unneccessary memcpy | 124 std::string dicom; |
122 std::string postData; | 125 |
123 call.BodyToString(postData); | 126 if (boost::iequals(call.GetHttpHeader("content-encoding", ""), "gzip")) |
127 { | |
128 GzipCompressor compressor; | |
129 compressor.Uncompress(dicom, call.GetBodyData(), call.GetBodySize()); | |
130 } | |
131 else | |
132 { | |
133 // TODO Remove unneccessary memcpy | |
134 call.BodyToString(dicom); | |
135 } | |
124 | 136 |
125 DicomInstanceToStore toStore; | 137 DicomInstanceToStore toStore; |
126 toStore.SetOrigin(DicomInstanceOrigin::FromRest(call)); | 138 toStore.SetOrigin(DicomInstanceOrigin::FromRest(call)); |
127 toStore.SetBuffer(postData); | 139 toStore.SetBuffer(dicom); |
128 | 140 |
129 std::string publicId; | 141 std::string publicId; |
130 StoreStatus status = context.Store(publicId, toStore); | 142 StoreStatus status = context.Store(publicId, toStore); |
131 | 143 |
132 OrthancRestApi::GetApi(call).AnswerStoredInstance(call, toStore, status); | 144 OrthancRestApi::GetApi(call).AnswerStoredInstance(call, toStore, status); |