Mercurial > hg > orthanc
comparison PalantirCppClient/HttpException.cpp @ 0:3959d33612cc
initial commit
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 19 Jul 2012 14:32:22 +0200 |
parents | |
children | 9be852ad33d2 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3959d33612cc |
---|---|
1 /** | |
2 * Palantir - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, | |
4 * Belgium | |
5 * | |
6 * Permission is hereby granted, free of charge, to any person | |
7 * obtaining a copy of this software and associated documentation | |
8 * files (the "Software"), to deal in the Software without | |
9 * restriction, including without limitation the rights to use, copy, | |
10 * modify, merge, publish, distribute, sublicense, and/or sell copies | |
11 * of the Software, and to permit persons to whom the Software is | |
12 * furnished to do so, subject to the following conditions: | |
13 * | |
14 * The above copyright notice and this permission notice shall be | |
15 * included in all copies or substantial portions of the Software. | |
16 * | |
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | |
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | |
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
24 * SOFTWARE. | |
25 **/ | |
26 | |
27 | |
28 #include "HttpException.h" | |
29 | |
30 namespace Palantir | |
31 { | |
32 const char* HttpException::What() const | |
33 { | |
34 if (status_ == HttpStatus_None) | |
35 { | |
36 return custom_.c_str(); | |
37 } | |
38 else | |
39 { | |
40 return GetDescription(status_); | |
41 } | |
42 } | |
43 | |
44 const char* HttpException::GetDescription(HttpStatus status) | |
45 { | |
46 switch (status) | |
47 { | |
48 case HttpStatus_100_Continue: | |
49 return "Continue"; | |
50 | |
51 case HttpStatus_101_SwitchingProtocols: | |
52 return "Switching Protocols"; | |
53 | |
54 case HttpStatus_102_Processing: | |
55 return "Processing"; | |
56 | |
57 case HttpStatus_200_Ok: | |
58 return "OK"; | |
59 | |
60 case HttpStatus_201_Created: | |
61 return "Created"; | |
62 | |
63 case HttpStatus_202_Accepted: | |
64 return "Accepted"; | |
65 | |
66 case HttpStatus_203_NonAuthoritativeInformation: | |
67 return "Non-Authoritative Information"; | |
68 | |
69 case HttpStatus_204_NoContent: | |
70 return "No Content"; | |
71 | |
72 case HttpStatus_205_ResetContent: | |
73 return "Reset Content"; | |
74 | |
75 case HttpStatus_206_PartialContent: | |
76 return "Partial Content"; | |
77 | |
78 case HttpStatus_207_MultiStatus: | |
79 return "Multi-Status"; | |
80 | |
81 case HttpStatus_208_AlreadyReported: | |
82 return "Already Reported"; | |
83 | |
84 case HttpStatus_226_IMUsed: | |
85 return "IM Used"; | |
86 | |
87 case HttpStatus_300_MultipleChoices: | |
88 return "Multiple Choices"; | |
89 | |
90 case HttpStatus_301_MovedPermanently: | |
91 return "Moved Permanently"; | |
92 | |
93 case HttpStatus_302_Found: | |
94 return "Found"; | |
95 | |
96 case HttpStatus_303_SeeOther: | |
97 return "See Other"; | |
98 | |
99 case HttpStatus_304_NotModified: | |
100 return "Not Modified"; | |
101 | |
102 case HttpStatus_305_UseProxy: | |
103 return "Use Proxy"; | |
104 | |
105 case HttpStatus_307_TemporaryRedirect: | |
106 return "Temporary Redirect"; | |
107 | |
108 case HttpStatus_400_BadRequest: | |
109 return "Bad Request"; | |
110 | |
111 case HttpStatus_401_Unauthorized: | |
112 return "Unauthorized"; | |
113 | |
114 case HttpStatus_402_PaymentRequired: | |
115 return "Payment Required"; | |
116 | |
117 case HttpStatus_403_Forbidden: | |
118 return "Forbidden"; | |
119 | |
120 case HttpStatus_404_NotFound: | |
121 return "Not Found"; | |
122 | |
123 case HttpStatus_405_MethodNotAllowed: | |
124 return "Method Not Allowed"; | |
125 | |
126 case HttpStatus_406_NotAcceptable: | |
127 return "Not Acceptable"; | |
128 | |
129 case HttpStatus_407_ProxyAuthenticationRequired: | |
130 return "Proxy Authentication Required"; | |
131 | |
132 case HttpStatus_408_RequestTimeout: | |
133 return "Request Timeout"; | |
134 | |
135 case HttpStatus_409_Conflict: | |
136 return "Conflict"; | |
137 | |
138 case HttpStatus_410_Gone: | |
139 return "Gone"; | |
140 | |
141 case HttpStatus_411_LengthRequired: | |
142 return "Length Required"; | |
143 | |
144 case HttpStatus_412_PreconditionFailed: | |
145 return "Precondition Failed"; | |
146 | |
147 case HttpStatus_413_RequestEntityTooLarge: | |
148 return "Request Entity Too Large"; | |
149 | |
150 case HttpStatus_414_RequestUriTooLong: | |
151 return "Request-URI Too Long"; | |
152 | |
153 case HttpStatus_415_UnsupportedMediaType: | |
154 return "Unsupported Media Type"; | |
155 | |
156 case HttpStatus_416_RequestedRangeNotSatisfiable: | |
157 return "Requested Range Not Satisfiable"; | |
158 | |
159 case HttpStatus_417_ExpectationFailed: | |
160 return "Expectation Failed"; | |
161 | |
162 case HttpStatus_422_UnprocessableEntity: | |
163 return "Unprocessable Entity"; | |
164 | |
165 case HttpStatus_423_Locked: | |
166 return "Locked"; | |
167 | |
168 case HttpStatus_424_FailedDependency: | |
169 return "Failed Dependency"; | |
170 | |
171 case HttpStatus_426_UpgradeRequired: | |
172 return "Upgrade Required"; | |
173 | |
174 case HttpStatus_500_InternalServerError: | |
175 return "Internal Server Error"; | |
176 | |
177 case HttpStatus_501_NotImplemented: | |
178 return "Not Implemented"; | |
179 | |
180 case HttpStatus_502_BadGateway: | |
181 return "Bad Gateway"; | |
182 | |
183 case HttpStatus_503_ServiceUnavailable: | |
184 return "Service Unavailable"; | |
185 | |
186 case HttpStatus_504_GatewayTimeout: | |
187 return "Gateway Timeout"; | |
188 | |
189 case HttpStatus_505_HttpVersionNotSupported: | |
190 return "HTTP Version Not Supported"; | |
191 | |
192 case HttpStatus_506_VariantAlsoNegotiates: | |
193 return "Variant Also Negotiates"; | |
194 | |
195 case HttpStatus_507_InsufficientStorage: | |
196 return "Insufficient Storage"; | |
197 | |
198 case HttpStatus_509_BandwidthLimitExceeded: | |
199 return "Bandwidth Limit Exceeded"; | |
200 | |
201 case HttpStatus_510_NotExtended: | |
202 return "Not Extended"; | |
203 | |
204 default: | |
205 throw HttpException("Unknown HTTP status"); | |
206 } | |
207 } | |
208 } |