Mercurial > hg > orthanc
diff Core/HttpServer/MongooseServer.cpp @ 355:753e69f9326e
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 30 Jan 2013 17:56:44 +0100 |
parents | 795ce0fa8e8a |
children | bdd72233b105 |
line wrap: on
line diff
--- a/Core/HttpServer/MongooseServer.cpp Wed Jan 30 14:34:36 2013 +0100 +++ b/Core/HttpServer/MongooseServer.cpp Wed Jan 30 17:56:44 2013 +0100 @@ -464,6 +464,30 @@ MongooseServer* that = (MongooseServer*) (request->user_data); MongooseOutput output(connection); + // Compute the method + Orthanc_HttpMethod method; + if (!strcmp(request->request_method, "GET")) + { + method = Orthanc_HttpMethod_Get; + } + else if (!strcmp(request->request_method, "POST")) + { + method = Orthanc_HttpMethod_Post; + } + else if (!strcmp(request->request_method, "DELETE")) + { + method = Orthanc_HttpMethod_Delete; + } + else if (!strcmp(request->request_method, "PUT")) + { + method = Orthanc_HttpMethod_Put; + } + else + { + output.SendHeader(Orthanc_HttpStatus_405_MethodNotAllowed); + return (void*) ""; + } + if (!that->IsRemoteAccessAllowed() && request->remote_ip != LOCALHOST) { @@ -489,12 +513,12 @@ std::string postData; - if (!strcmp(request->request_method, "GET")) + if (method == Orthanc_HttpMethod_Get) { HttpHandler::ParseGetQuery(arguments, request->query_string); } - else if (!strcmp(request->request_method, "POST") || - !strcmp(request->request_method, "PUT")) + else if (method == Orthanc_HttpMethod_Post || + method == Orthanc_HttpMethod_Put) { HttpHandler::Arguments::const_iterator ct = headers.find("content-type"); if (ct == headers.end()) @@ -543,8 +567,7 @@ { try { - handler->Handle(output, std::string(request->request_method), - uri, headers, arguments, postData); + handler->Handle(output, method, uri, headers, arguments, postData); } catch (OrthancException& e) {