Mercurial > hg > orthanc
diff OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 1781:5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 17 Nov 2015 17:46:32 +0100 |
parents | 613df4362575 |
children | 2dbf25006f88 |
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Fri Nov 13 15:06:45 2015 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Tue Nov 17 17:46:32 2015 +0100 @@ -259,6 +259,32 @@ } + static void AnswerImage(RestApiGetCall& call, + ParsedDicomFile& dicom, + unsigned int frame, + ImageExtractionMode mode) + { + typedef std::vector<std::string> MediaRanges; + + // Get the HTTP "Accept" header, if any + std::string accept = call.GetHttpHeader("accept", "*/*"); + + MediaRanges mediaRanges; + Toolbox::TokenizeString(mediaRanges, accept, ','); + + for (MediaRanges::const_reverse_iterator it = mediaRanges.rbegin(); + it != mediaRanges.rend(); ++it) + { + } + + throw OrthancException(ErrorCode_NotAcceptable); + + std::string image; + dicom.ExtractPngImage(image, frame, mode); + call.GetOutput().AnswerBuffer(image, "image/png"); + } + + template <enum ImageExtractionMode mode> static void GetImage(RestApiGetCall& call) { @@ -277,15 +303,14 @@ } std::string publicId = call.GetUriComponent("id", ""); - std::string dicomContent, png; + std::string dicomContent; context.ReadFile(dicomContent, publicId, FileContentType_Dicom); ParsedDicomFile dicom(dicomContent); try { - dicom.ExtractPngImage(png, frame, mode); - call.GetOutput().AnswerBuffer(png, "image/png"); + AnswerImage(call, dicom, frame, mode); } catch (OrthancException& e) {