Mercurial > hg > orthanc
comparison OrthancCppClient/HttpException.cpp @ 60:77aec9be0a51 orthanc-renaming
renaming of cppclient
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 16 Sep 2012 09:29:54 +0200 |
parents | 4bc019d2f969 |
children | e3a40c7846b8 |
comparison
equal
deleted
inserted
replaced
59:c996319e90bc | 60:77aec9be0a51 |
---|---|
1 /** | 1 /** |
2 * Palanthir - A Lightweight, RESTful DICOM Store | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, | 3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, |
4 * Belgium | 4 * Belgium |
5 * | 5 * |
6 * Permission is hereby granted, free of charge, to any person | 6 * Permission is hereby granted, free of charge, to any person |
7 * obtaining a copy of this software and associated documentation | 7 * obtaining a copy of this software and associated documentation |
25 **/ | 25 **/ |
26 | 26 |
27 | 27 |
28 #include "HttpException.h" | 28 #include "HttpException.h" |
29 | 29 |
30 namespace Palanthir | 30 namespace Orthanc |
31 { | 31 { |
32 const char* HttpException::What() const | 32 const char* HttpException::What() const |
33 { | 33 { |
34 if (status_ == Palanthir_HttpStatus_None) | 34 if (status_ == Orthanc_HttpStatus_None) |
35 { | 35 { |
36 return custom_.c_str(); | 36 return custom_.c_str(); |
37 } | 37 } |
38 else | 38 else |
39 { | 39 { |
40 return GetDescription(status_); | 40 return GetDescription(status_); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 const char* HttpException::GetDescription(Palanthir_HttpStatus status) | 44 const char* HttpException::GetDescription(Orthanc_HttpStatus status) |
45 { | 45 { |
46 switch (status) | 46 switch (status) |
47 { | 47 { |
48 case Palanthir_HttpStatus_100_Continue: | 48 case Orthanc_HttpStatus_100_Continue: |
49 return "Continue"; | 49 return "Continue"; |
50 | 50 |
51 case Palanthir_HttpStatus_101_SwitchingProtocols: | 51 case Orthanc_HttpStatus_101_SwitchingProtocols: |
52 return "Switching Protocols"; | 52 return "Switching Protocols"; |
53 | 53 |
54 case Palanthir_HttpStatus_102_Processing: | 54 case Orthanc_HttpStatus_102_Processing: |
55 return "Processing"; | 55 return "Processing"; |
56 | 56 |
57 case Palanthir_HttpStatus_200_Ok: | 57 case Orthanc_HttpStatus_200_Ok: |
58 return "OK"; | 58 return "OK"; |
59 | 59 |
60 case Palanthir_HttpStatus_201_Created: | 60 case Orthanc_HttpStatus_201_Created: |
61 return "Created"; | 61 return "Created"; |
62 | 62 |
63 case Palanthir_HttpStatus_202_Accepted: | 63 case Orthanc_HttpStatus_202_Accepted: |
64 return "Accepted"; | 64 return "Accepted"; |
65 | 65 |
66 case Palanthir_HttpStatus_203_NonAuthoritativeInformation: | 66 case Orthanc_HttpStatus_203_NonAuthoritativeInformation: |
67 return "Non-Authoritative Information"; | 67 return "Non-Authoritative Information"; |
68 | 68 |
69 case Palanthir_HttpStatus_204_NoContent: | 69 case Orthanc_HttpStatus_204_NoContent: |
70 return "No Content"; | 70 return "No Content"; |
71 | 71 |
72 case Palanthir_HttpStatus_205_ResetContent: | 72 case Orthanc_HttpStatus_205_ResetContent: |
73 return "Reset Content"; | 73 return "Reset Content"; |
74 | 74 |
75 case Palanthir_HttpStatus_206_PartialContent: | 75 case Orthanc_HttpStatus_206_PartialContent: |
76 return "Partial Content"; | 76 return "Partial Content"; |
77 | 77 |
78 case Palanthir_HttpStatus_207_MultiStatus: | 78 case Orthanc_HttpStatus_207_MultiStatus: |
79 return "Multi-Status"; | 79 return "Multi-Status"; |
80 | 80 |
81 case Palanthir_HttpStatus_208_AlreadyReported: | 81 case Orthanc_HttpStatus_208_AlreadyReported: |
82 return "Already Reported"; | 82 return "Already Reported"; |
83 | 83 |
84 case Palanthir_HttpStatus_226_IMUsed: | 84 case Orthanc_HttpStatus_226_IMUsed: |
85 return "IM Used"; | 85 return "IM Used"; |
86 | 86 |
87 case Palanthir_HttpStatus_300_MultipleChoices: | 87 case Orthanc_HttpStatus_300_MultipleChoices: |
88 return "Multiple Choices"; | 88 return "Multiple Choices"; |
89 | 89 |
90 case Palanthir_HttpStatus_301_MovedPermanently: | 90 case Orthanc_HttpStatus_301_MovedPermanently: |
91 return "Moved Permanently"; | 91 return "Moved Permanently"; |
92 | 92 |
93 case Palanthir_HttpStatus_302_Found: | 93 case Orthanc_HttpStatus_302_Found: |
94 return "Found"; | 94 return "Found"; |
95 | 95 |
96 case Palanthir_HttpStatus_303_SeeOther: | 96 case Orthanc_HttpStatus_303_SeeOther: |
97 return "See Other"; | 97 return "See Other"; |
98 | 98 |
99 case Palanthir_HttpStatus_304_NotModified: | 99 case Orthanc_HttpStatus_304_NotModified: |
100 return "Not Modified"; | 100 return "Not Modified"; |
101 | 101 |
102 case Palanthir_HttpStatus_305_UseProxy: | 102 case Orthanc_HttpStatus_305_UseProxy: |
103 return "Use Proxy"; | 103 return "Use Proxy"; |
104 | 104 |
105 case Palanthir_HttpStatus_307_TemporaryRedirect: | 105 case Orthanc_HttpStatus_307_TemporaryRedirect: |
106 return "Temporary Redirect"; | 106 return "Temporary Redirect"; |
107 | 107 |
108 case Palanthir_HttpStatus_400_BadRequest: | 108 case Orthanc_HttpStatus_400_BadRequest: |
109 return "Bad Request"; | 109 return "Bad Request"; |
110 | 110 |
111 case Palanthir_HttpStatus_401_Unauthorized: | 111 case Orthanc_HttpStatus_401_Unauthorized: |
112 return "Unauthorized"; | 112 return "Unauthorized"; |
113 | 113 |
114 case Palanthir_HttpStatus_402_PaymentRequired: | 114 case Orthanc_HttpStatus_402_PaymentRequired: |
115 return "Payment Required"; | 115 return "Payment Required"; |
116 | 116 |
117 case Palanthir_HttpStatus_403_Forbidden: | 117 case Orthanc_HttpStatus_403_Forbidden: |
118 return "Forbidden"; | 118 return "Forbidden"; |
119 | 119 |
120 case Palanthir_HttpStatus_404_NotFound: | 120 case Orthanc_HttpStatus_404_NotFound: |
121 return "Not Found"; | 121 return "Not Found"; |
122 | 122 |
123 case Palanthir_HttpStatus_405_MethodNotAllowed: | 123 case Orthanc_HttpStatus_405_MethodNotAllowed: |
124 return "Method Not Allowed"; | 124 return "Method Not Allowed"; |
125 | 125 |
126 case Palanthir_HttpStatus_406_NotAcceptable: | 126 case Orthanc_HttpStatus_406_NotAcceptable: |
127 return "Not Acceptable"; | 127 return "Not Acceptable"; |
128 | 128 |
129 case Palanthir_HttpStatus_407_ProxyAuthenticationRequired: | 129 case Orthanc_HttpStatus_407_ProxyAuthenticationRequired: |
130 return "Proxy Authentication Required"; | 130 return "Proxy Authentication Required"; |
131 | 131 |
132 case Palanthir_HttpStatus_408_RequestTimeout: | 132 case Orthanc_HttpStatus_408_RequestTimeout: |
133 return "Request Timeout"; | 133 return "Request Timeout"; |
134 | 134 |
135 case Palanthir_HttpStatus_409_Conflict: | 135 case Orthanc_HttpStatus_409_Conflict: |
136 return "Conflict"; | 136 return "Conflict"; |
137 | 137 |
138 case Palanthir_HttpStatus_410_Gone: | 138 case Orthanc_HttpStatus_410_Gone: |
139 return "Gone"; | 139 return "Gone"; |
140 | 140 |
141 case Palanthir_HttpStatus_411_LengthRequired: | 141 case Orthanc_HttpStatus_411_LengthRequired: |
142 return "Length Required"; | 142 return "Length Required"; |
143 | 143 |
144 case Palanthir_HttpStatus_412_PreconditionFailed: | 144 case Orthanc_HttpStatus_412_PreconditionFailed: |
145 return "Precondition Failed"; | 145 return "Precondition Failed"; |
146 | 146 |
147 case Palanthir_HttpStatus_413_RequestEntityTooLarge: | 147 case Orthanc_HttpStatus_413_RequestEntityTooLarge: |
148 return "Request Entity Too Large"; | 148 return "Request Entity Too Large"; |
149 | 149 |
150 case Palanthir_HttpStatus_414_RequestUriTooLong: | 150 case Orthanc_HttpStatus_414_RequestUriTooLong: |
151 return "Request-URI Too Long"; | 151 return "Request-URI Too Long"; |
152 | 152 |
153 case Palanthir_HttpStatus_415_UnsupportedMediaType: | 153 case Orthanc_HttpStatus_415_UnsupportedMediaType: |
154 return "Unsupported Media Type"; | 154 return "Unsupported Media Type"; |
155 | 155 |
156 case Palanthir_HttpStatus_416_RequestedRangeNotSatisfiable: | 156 case Orthanc_HttpStatus_416_RequestedRangeNotSatisfiable: |
157 return "Requested Range Not Satisfiable"; | 157 return "Requested Range Not Satisfiable"; |
158 | 158 |
159 case Palanthir_HttpStatus_417_ExpectationFailed: | 159 case Orthanc_HttpStatus_417_ExpectationFailed: |
160 return "Expectation Failed"; | 160 return "Expectation Failed"; |
161 | 161 |
162 case Palanthir_HttpStatus_422_UnprocessableEntity: | 162 case Orthanc_HttpStatus_422_UnprocessableEntity: |
163 return "Unprocessable Entity"; | 163 return "Unprocessable Entity"; |
164 | 164 |
165 case Palanthir_HttpStatus_423_Locked: | 165 case Orthanc_HttpStatus_423_Locked: |
166 return "Locked"; | 166 return "Locked"; |
167 | 167 |
168 case Palanthir_HttpStatus_424_FailedDependency: | 168 case Orthanc_HttpStatus_424_FailedDependency: |
169 return "Failed Dependency"; | 169 return "Failed Dependency"; |
170 | 170 |
171 case Palanthir_HttpStatus_426_UpgradeRequired: | 171 case Orthanc_HttpStatus_426_UpgradeRequired: |
172 return "Upgrade Required"; | 172 return "Upgrade Required"; |
173 | 173 |
174 case Palanthir_HttpStatus_500_InternalServerError: | 174 case Orthanc_HttpStatus_500_InternalServerError: |
175 return "Internal Server Error"; | 175 return "Internal Server Error"; |
176 | 176 |
177 case Palanthir_HttpStatus_501_NotImplemented: | 177 case Orthanc_HttpStatus_501_NotImplemented: |
178 return "Not Implemented"; | 178 return "Not Implemented"; |
179 | 179 |
180 case Palanthir_HttpStatus_502_BadGateway: | 180 case Orthanc_HttpStatus_502_BadGateway: |
181 return "Bad Gateway"; | 181 return "Bad Gateway"; |
182 | 182 |
183 case Palanthir_HttpStatus_503_ServiceUnavailable: | 183 case Orthanc_HttpStatus_503_ServiceUnavailable: |
184 return "Service Unavailable"; | 184 return "Service Unavailable"; |
185 | 185 |
186 case Palanthir_HttpStatus_504_GatewayTimeout: | 186 case Orthanc_HttpStatus_504_GatewayTimeout: |
187 return "Gateway Timeout"; | 187 return "Gateway Timeout"; |
188 | 188 |
189 case Palanthir_HttpStatus_505_HttpVersionNotSupported: | 189 case Orthanc_HttpStatus_505_HttpVersionNotSupported: |
190 return "HTTP Version Not Supported"; | 190 return "HTTP Version Not Supported"; |
191 | 191 |
192 case Palanthir_HttpStatus_506_VariantAlsoNegotiates: | 192 case Orthanc_HttpStatus_506_VariantAlsoNegotiates: |
193 return "Variant Also Negotiates"; | 193 return "Variant Also Negotiates"; |
194 | 194 |
195 case Palanthir_HttpStatus_507_InsufficientStorage: | 195 case Orthanc_HttpStatus_507_InsufficientStorage: |
196 return "Insufficient Storage"; | 196 return "Insufficient Storage"; |
197 | 197 |
198 case Palanthir_HttpStatus_509_BandwidthLimitExceeded: | 198 case Orthanc_HttpStatus_509_BandwidthLimitExceeded: |
199 return "Bandwidth Limit Exceeded"; | 199 return "Bandwidth Limit Exceeded"; |
200 | 200 |
201 case Palanthir_HttpStatus_510_NotExtended: | 201 case Orthanc_HttpStatus_510_NotExtended: |
202 return "Not Extended"; | 202 return "Not Extended"; |
203 | 203 |
204 default: | 204 default: |
205 throw HttpException("Unknown HTTP status"); | 205 throw HttpException("Unknown HTTP status"); |
206 } | 206 } |