Mercurial > hg > orthanc
comparison Core/HttpServer/HttpOutput.cpp @ 473:c9a5d72f8481
changing the namespace of HTTP enumerations
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 15 Jul 2013 17:22:13 +0200 |
parents | bdd72233b105 |
children | a9693dc7089c |
comparison
equal
deleted
inserted
replaced
472:722b56b99093 | 473:c9a5d72f8481 |
---|---|
102 | 102 |
103 | 103 |
104 void HttpOutput::SendMethodNotAllowedError(const std::string& allowed) | 104 void HttpOutput::SendMethodNotAllowedError(const std::string& allowed) |
105 { | 105 { |
106 std::string s = | 106 std::string s = |
107 "HTTP/1.1 405 " + std::string(HttpException::GetDescription(Orthanc_HttpStatus_405_MethodNotAllowed)) + | 107 "HTTP/1.1 405 " + std::string(HttpException::GetDescription(HttpStatus_405_MethodNotAllowed)) + |
108 "\r\nAllow: " + allowed + | 108 "\r\nAllow: " + allowed + |
109 "\r\n\r\n"; | 109 "\r\n\r\n"; |
110 Send(&s[0], s.size()); | 110 Send(&s[0], s.size()); |
111 } | 111 } |
112 | 112 |
113 | 113 |
114 void HttpOutput::SendHeader(Orthanc_HttpStatus status) | 114 void HttpOutput::SendHeader(HttpStatus status) |
115 { | 115 { |
116 if (status == Orthanc_HttpStatus_200_Ok || | 116 if (status == HttpStatus_200_Ok || |
117 status == Orthanc_HttpStatus_405_MethodNotAllowed) | 117 status == HttpStatus_405_MethodNotAllowed) |
118 { | 118 { |
119 throw OrthancException("Please use the dedicated methods to this HTTP status code in HttpOutput"); | 119 throw OrthancException("Please use the dedicated methods to this HTTP status code in HttpOutput"); |
120 } | 120 } |
121 | 121 |
122 SendHeaderInternal(status); | 122 SendHeaderInternal(status); |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 void HttpOutput::SendHeaderInternal(Orthanc_HttpStatus status) | 126 void HttpOutput::SendHeaderInternal(HttpStatus status) |
127 { | 127 { |
128 std::string s = "HTTP/1.1 " + | 128 std::string s = "HTTP/1.1 " + |
129 boost::lexical_cast<std::string>(status) + | 129 boost::lexical_cast<std::string>(status) + |
130 " " + std::string(HttpException::GetDescription(status)) + | 130 " " + std::string(HttpException::GetDescription(status)) + |
131 "\r\n\r\n"; | 131 "\r\n\r\n"; |
188 | 188 |
189 | 189 |
190 void HttpOutput::Redirect(const std::string& path) | 190 void HttpOutput::Redirect(const std::string& path) |
191 { | 191 { |
192 std::string s = | 192 std::string s = |
193 "HTTP/1.1 301 " + std::string(HttpException::GetDescription(Orthanc_HttpStatus_301_MovedPermanently)) + | 193 "HTTP/1.1 301 " + std::string(HttpException::GetDescription(HttpStatus_301_MovedPermanently)) + |
194 "\r\nLocation: " + path + | 194 "\r\nLocation: " + path + |
195 "\r\n\r\n"; | 195 "\r\n\r\n"; |
196 Send(&s[0], s.size()); | 196 Send(&s[0], s.size()); |
197 } | 197 } |
198 } | 198 } |