comparison OrthancServer/OrthancRestApi/OrthancRestApi.cpp @ 3491:22bdb9c91ebf

Log an explicit error if uploading an empty DICOM file using REST API
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 16 Aug 2019 14:38:15 +0200
parents 962e5f00744b
children 94f4a18a79cc
comparison
equal deleted inserted replaced
3490:786fce009be8 3491:22bdb9c91ebf
108 108
109 static void UploadDicomFile(RestApiPostCall& call) 109 static void UploadDicomFile(RestApiPostCall& call)
110 { 110 {
111 ServerContext& context = OrthancRestApi::GetContext(call); 111 ServerContext& context = OrthancRestApi::GetContext(call);
112 112
113 LOG(INFO) << "Receiving a DICOM file of " << call.GetBodySize() << " bytes through HTTP";
114
113 if (call.GetBodySize() == 0) 115 if (call.GetBodySize() == 0)
114 { 116 {
115 return; 117 throw OrthancException(ErrorCode_BadFileFormat,
116 } 118 "Received an empty DICOM file");
117 119 }
118 LOG(INFO) << "Receiving a DICOM file of " << call.GetBodySize() << " bytes through HTTP";
119 120
120 // TODO Remove unneccessary memcpy 121 // TODO Remove unneccessary memcpy
121 std::string postData; 122 std::string postData;
122 call.BodyToString(postData); 123 call.BodyToString(postData);
123 124