comparison 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
comparison
equal deleted inserted replaced
2045:21a8ca9ad928 2046:b534834a300e
37 37
38 namespace Orthanc 38 namespace Orthanc
39 { 39 {
40 void StringHttpOutput::OnHttpStatusReceived(HttpStatus status) 40 void StringHttpOutput::OnHttpStatusReceived(HttpStatus status)
41 { 41 {
42 if (status != HttpStatus_200_Ok && 42 switch (status)
43 status != HttpStatus_404_NotFound)
44 { 43 {
45 throw OrthancException(ErrorCode_BadRequest); 44 case HttpStatus_200_Ok:
45 found_ = true;
46 break;
47
48 case HttpStatus_404_NotFound:
49 found_ = false;
50 break;
51
52 default:
53 throw OrthancException(ErrorCode_BadRequest);
46 } 54 }
47 } 55 }
48 56
49 void StringHttpOutput::Send(bool isHeader, const void* buffer, size_t length) 57 void StringHttpOutput::Send(bool isHeader, const void* buffer, size_t length)
50 { 58 {
51 if (!isHeader) 59 if (!isHeader)
52 { 60 {
53 buffer_.AddChunk(reinterpret_cast<const char*>(buffer), length); 61 buffer_.AddChunk(reinterpret_cast<const char*>(buffer), length);
54 } 62 }
55 } 63 }
64
65 void StringHttpOutput::GetOutput(std::string& output)
66 {
67 if (found_)
68 {
69 buffer_.Flatten(output);
70 }
71 else
72 {
73 throw OrthancException(ErrorCode_UnknownResource);
74 }
75 }
56 } 76 }