diff Core/HttpServer/StringHttpOutput.cpp @ 2046:b534834a300e

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 24 Jun 2016 20:49:13 +0200
parents 3fcea6dc151d
children a3a65de1840f
line wrap: on
line diff
--- a/Core/HttpServer/StringHttpOutput.cpp	Fri Jun 24 11:42:23 2016 +0200
+++ b/Core/HttpServer/StringHttpOutput.cpp	Fri Jun 24 20:49:13 2016 +0200
@@ -39,10 +39,18 @@
 {
   void StringHttpOutput::OnHttpStatusReceived(HttpStatus status)
   {
-    if (status != HttpStatus_200_Ok &&
-        status != HttpStatus_404_NotFound)
+    switch (status)
     {
-      throw OrthancException(ErrorCode_BadRequest);
+      case HttpStatus_200_Ok:
+        found_ = true;
+        break;
+
+      case HttpStatus_404_NotFound:
+        found_ = false;
+        break;
+
+      default:
+        throw OrthancException(ErrorCode_BadRequest);
     }
   }
 
@@ -53,4 +61,16 @@
       buffer_.AddChunk(reinterpret_cast<const char*>(buffer), length);
     }
   }
+
+  void StringHttpOutput::GetOutput(std::string& output)
+  {
+    if (found_)
+    {
+      buffer_.Flatten(output);
+    }
+    else
+    {
+      throw OrthancException(ErrorCode_UnknownResource);
+    }
+  }
 }