changeset 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 786fce009be8
children c465c6ee2bfb
files NEWS OrthancServer/OrthancRestApi/OrthancRestApi.cpp
diffstat 2 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Sat Aug 10 13:42:38 2019 +0200
+++ b/NEWS	Fri Aug 16 14:38:15 2019 +0200
@@ -4,6 +4,7 @@
 Maintenance
 -----------
 
+* Log an explicit error if uploading an empty DICOM file using REST API
 * Fix compatibility of LSB binaries with Ubuntu >= 18.04
 
 
--- a/OrthancServer/OrthancRestApi/OrthancRestApi.cpp	Sat Aug 10 13:42:38 2019 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestApi.cpp	Fri Aug 16 14:38:15 2019 +0200
@@ -110,13 +110,14 @@
   {
     ServerContext& context = OrthancRestApi::GetContext(call);
 
+    LOG(INFO) << "Receiving a DICOM file of " << call.GetBodySize() << " bytes through HTTP";
+
     if (call.GetBodySize() == 0)
     {
-      return;
+      throw OrthancException(ErrorCode_BadFileFormat,
+                             "Received an empty DICOM file");
     }
 
-    LOG(INFO) << "Receiving a DICOM file of " << call.GetBodySize() << " bytes through HTTP";
-
     // TODO Remove unneccessary memcpy
     std::string postData;
     call.BodyToString(postData);