Mercurial > hg > orthanc
comparison Core/RestApi/RestApi.cpp @ 416:1188cb0ddaa5
http method faking
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 06 May 2013 16:32:27 +0200 |
parents | bdd72233b105 |
children | c9a5d72f8481 |
comparison
equal
deleted
inserted
replaced
415:d558fa565c42 | 416:1188cb0ddaa5 |
---|---|
196 for (GetHandlers::const_iterator it = getHandlers_.begin(); | 196 for (GetHandlers::const_iterator it = getHandlers_.begin(); |
197 it != getHandlers_.end(); it++) | 197 it != getHandlers_.end(); it++) |
198 { | 198 { |
199 if (it->first->Match(components, trailing, uri)) | 199 if (it->first->Match(components, trailing, uri)) |
200 { | 200 { |
201 LOG(INFO) << "REST GET call on: " << Toolbox::FlattenUri(uri); | 201 //LOG(INFO) << "REST GET call on: " << Toolbox::FlattenUri(uri); |
202 ok = true; | 202 ok = true; |
203 GetCall call; | 203 GetCall call; |
204 call.output_ = &restOutput; | 204 call.output_ = &restOutput; |
205 call.context_ = this; | 205 call.context_ = this; |
206 call.httpHeaders_ = &headers; | 206 call.httpHeaders_ = &headers; |
218 for (PutHandlers::const_iterator it = putHandlers_.begin(); | 218 for (PutHandlers::const_iterator it = putHandlers_.begin(); |
219 it != putHandlers_.end(); it++) | 219 it != putHandlers_.end(); it++) |
220 { | 220 { |
221 if (it->first->Match(components, trailing, uri)) | 221 if (it->first->Match(components, trailing, uri)) |
222 { | 222 { |
223 LOG(INFO) << "REST PUT call on: " << Toolbox::FlattenUri(uri); | 223 //LOG(INFO) << "REST PUT call on: " << Toolbox::FlattenUri(uri); |
224 ok = true; | 224 ok = true; |
225 PutCall call; | 225 PutCall call; |
226 call.output_ = &restOutput; | 226 call.output_ = &restOutput; |
227 call.context_ = this; | 227 call.context_ = this; |
228 call.httpHeaders_ = &headers; | 228 call.httpHeaders_ = &headers; |
240 for (PostHandlers::const_iterator it = postHandlers_.begin(); | 240 for (PostHandlers::const_iterator it = postHandlers_.begin(); |
241 it != postHandlers_.end(); it++) | 241 it != postHandlers_.end(); it++) |
242 { | 242 { |
243 if (it->first->Match(components, trailing, uri)) | 243 if (it->first->Match(components, trailing, uri)) |
244 { | 244 { |
245 LOG(INFO) << "REST POST call on: " << Toolbox::FlattenUri(uri); | 245 //LOG(INFO) << "REST POST call on: " << Toolbox::FlattenUri(uri); |
246 ok = true; | 246 ok = true; |
247 PostCall call; | 247 PostCall call; |
248 call.output_ = &restOutput; | 248 call.output_ = &restOutput; |
249 call.context_ = this; | 249 call.context_ = this; |
250 call.httpHeaders_ = &headers; | 250 call.httpHeaders_ = &headers; |
262 for (DeleteHandlers::const_iterator it = deleteHandlers_.begin(); | 262 for (DeleteHandlers::const_iterator it = deleteHandlers_.begin(); |
263 it != deleteHandlers_.end(); it++) | 263 it != deleteHandlers_.end(); it++) |
264 { | 264 { |
265 if (it->first->Match(components, trailing, uri)) | 265 if (it->first->Match(components, trailing, uri)) |
266 { | 266 { |
267 LOG(INFO) << "REST DELETE call on: " << Toolbox::FlattenUri(uri); | 267 //LOG(INFO) << "REST DELETE call on: " << Toolbox::FlattenUri(uri); |
268 ok = true; | 268 ok = true; |
269 DeleteCall call; | 269 DeleteCall call; |
270 call.output_ = &restOutput; | 270 call.output_ = &restOutput; |
271 call.context_ = this; | 271 call.context_ = this; |
272 call.httpHeaders_ = &headers; | 272 call.httpHeaders_ = &headers; |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 if (!ok) | 281 if (!ok) |
282 { | 282 { |
283 LOG(INFO) << "REST method " << method << " not allowed on: " << Toolbox::FlattenUri(uri); | 283 LOG(INFO) << "REST method " << Orthanc_HttpMethod_ToString(method) |
284 << " not allowed on: " << Toolbox::FlattenUri(uri); | |
284 output.SendMethodNotAllowedError(GetAcceptedMethods(uri)); | 285 output.SendMethodNotAllowedError(GetAcceptedMethods(uri)); |
285 } | 286 } |
286 } | 287 } |
287 | 288 |
288 void RestApi::Register(const std::string& path, | 289 void RestApi::Register(const std::string& path, |