Mercurial > hg > orthanc
diff OrthancServer/OrthancRestApi/OrthancRestApi.cpp @ 3848:44bfcfdf42e8 transcoding
integration mainline->transcoding
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 20 Apr 2020 14:04:14 +0200 |
parents | 023b2a9f3aa1 be7df7fe3d80 |
children | 7610af1532c3 |
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestApi.cpp Wed Apr 15 22:03:21 2020 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestApi.cpp Mon Apr 20 14:04:14 2020 +0200 @@ -121,22 +121,23 @@ "Received an empty DICOM file"); } + // The lifetime of "dicom" must be longer than "toStore", as the + // latter can possibly store a reference to the former (*) std::string dicom; + DicomInstanceToStore toStore; + toStore.SetOrigin(DicomInstanceOrigin::FromRest(call)); + if (boost::iequals(call.GetHttpHeader("content-encoding", ""), "gzip")) { GzipCompressor compressor; compressor.Uncompress(dicom, call.GetBodyData(), call.GetBodySize()); + toStore.SetBuffer(dicom.c_str(), dicom.size()); // (*) } else { - // TODO Remove unneccessary memcpy - call.BodyToString(dicom); - } - - DicomInstanceToStore toStore; - toStore.SetOrigin(DicomInstanceOrigin::FromRest(call)); - toStore.SetBuffer(dicom); + toStore.SetBuffer(call.GetBodyData(), call.GetBodySize()); + } std::string publicId; StoreStatus status = context.Store(publicId, toStore, StoreInstanceMode_Default);