Mercurial > hg > orthanc
comparison Core/RestApi/RestApiOutput.cpp @ 2981:eff50153a7b3 db-changes
integration mainline->db-changes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 06 Dec 2018 15:58:08 +0100 |
parents | d924f9bb61cc |
children | 4e43e67f8ecf |
comparison
equal
deleted
inserted
replaced
2896:3fabf9a673f6 | 2981:eff50153a7b3 |
---|---|
94 if (convertJsonToXml_) | 94 if (convertJsonToXml_) |
95 { | 95 { |
96 #if ORTHANC_ENABLE_PUGIXML == 1 | 96 #if ORTHANC_ENABLE_PUGIXML == 1 |
97 std::string s; | 97 std::string s; |
98 Toolbox::JsonToXml(s, value); | 98 Toolbox::JsonToXml(s, value); |
99 output_.SetContentType("application/xml; charset=utf-8"); | 99 |
100 output_.SetContentType(MIME_XML_UTF8); | |
100 output_.Answer(s); | 101 output_.Answer(s); |
101 #else | 102 #else |
102 LOG(ERROR) << "Orthanc was compiled without XML support"; | 103 throw OrthancException(ErrorCode_InternalError, |
103 throw OrthancException(ErrorCode_InternalError); | 104 "Orthanc was compiled without XML support"); |
104 #endif | 105 #endif |
105 } | 106 } |
106 else | 107 else |
107 { | 108 { |
108 Json::StyledWriter writer; | 109 Json::StyledWriter writer; |
109 output_.SetContentType("application/json; charset=utf-8"); | 110 std::string s = writer.write(value); |
110 output_.Answer(writer.write(value)); | 111 |
112 output_.SetContentType(MIME_JSON_UTF8); | |
113 output_.Answer(s); | |
111 } | 114 } |
112 | 115 |
113 alreadySent_ = true; | 116 alreadySent_ = true; |
114 } | 117 } |
115 | 118 |
116 void RestApiOutput::AnswerBuffer(const std::string& buffer, | 119 void RestApiOutput::AnswerBuffer(const std::string& buffer, |
117 const std::string& contentType) | 120 MimeType contentType) |
118 { | 121 { |
119 AnswerBuffer(buffer.size() == 0 ? NULL : buffer.c_str(), | 122 AnswerBuffer(buffer.size() == 0 ? NULL : buffer.c_str(), |
120 buffer.size(), contentType); | 123 buffer.size(), contentType); |
121 } | 124 } |
122 | 125 |
123 void RestApiOutput::AnswerBuffer(const void* buffer, | 126 void RestApiOutput::AnswerBuffer(const void* buffer, |
124 size_t length, | 127 size_t length, |
125 const std::string& contentType) | 128 MimeType contentType) |
126 { | 129 { |
127 CheckStatus(); | 130 CheckStatus(); |
128 output_.SetContentType(contentType.c_str()); | 131 output_.SetContentType(contentType); |
129 output_.Answer(buffer, length); | 132 output_.Answer(buffer, length); |
130 alreadySent_ = true; | 133 alreadySent_ = true; |
131 } | 134 } |
132 | 135 |
133 void RestApiOutput::Redirect(const std::string& path) | 136 void RestApiOutput::Redirect(const std::string& path) |