Mercurial > hg > orthanc
diff Plugins/Engine/PluginsHttpHandler.cpp @ 1042:8d1845feb277
set cookies, not allowed methods, unauthorized in plugins
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 17 Jul 2014 15:55:40 +0200 |
parents | 2c49b7dffcec |
children | bb82e5e818e9 |
line wrap: on
line diff
--- a/Plugins/Engine/PluginsHttpHandler.cpp Thu Jul 17 14:14:15 2014 +0200 +++ b/Plugins/Engine/PluginsHttpHandler.cpp Thu Jul 17 15:55:40 2014 +0200 @@ -232,14 +232,14 @@ if (error < 0) { - LOG(ERROR) << "Plugin failed with error code " << error; + LOG(ERROR) << "Plugin callback failed with error code " << error; return false; } else { if (error > 0) { - LOG(WARNING) << "Plugin finished with warning code " << error; + LOG(WARNING) << "Plugin callback finished with warning code " << error; } return true; @@ -310,11 +310,51 @@ void PluginsHttpHandler::Redirect(const void* parameters) { - const _OrthancPluginRedirect& p = - *reinterpret_cast<const _OrthancPluginRedirect*>(parameters); + const _OrthancPluginOutputPlusArgument& p = + *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters); + + HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output); + translatedOutput->Redirect(p.argument); + } + + + void PluginsHttpHandler::SendHttpStatusCode(const void* parameters) + { + const _OrthancPluginSendHttpStatusCode& p = + *reinterpret_cast<const _OrthancPluginSendHttpStatusCode*>(parameters); HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output); - translatedOutput->Redirect(p.redirection); + translatedOutput->SendHeader(static_cast<HttpStatus>(p.status)); + } + + + void PluginsHttpHandler::SendUnauthorized(const void* parameters) + { + const _OrthancPluginOutputPlusArgument& p = + *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters); + + HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output); + translatedOutput->SendUnauthorized(p.argument); + } + + + void PluginsHttpHandler::SendMethodNotAllowed(const void* parameters) + { + const _OrthancPluginOutputPlusArgument& p = + *reinterpret_cast<const _OrthancPluginOutputPlusArgument*>(parameters); + + HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output); + translatedOutput->SendMethodNotAllowed(p.argument); + } + + + void PluginsHttpHandler::SetCookie(const void* parameters) + { + const _OrthancPluginSetCookie& p = + *reinterpret_cast<const _OrthancPluginSetCookie*>(parameters); + + HttpOutput* translatedOutput = reinterpret_cast<HttpOutput*>(p.output); + translatedOutput->SetCookie(p.cookie, p.value); } @@ -568,6 +608,22 @@ Redirect(parameters); return true; + case _OrthancPluginService_SendUnauthorized: + SendUnauthorized(parameters); + return true; + + case _OrthancPluginService_SendMethodNotAllowed: + SendMethodNotAllowed(parameters); + return true; + + case _OrthancPluginService_SendHttpStatusCode: + SendHttpStatusCode(parameters); + return true; + + case _OrthancPluginService_SetCookie: + SetCookie(parameters); + return true; + case _OrthancPluginService_LookupPatient: LookupResource(ResourceType_Patient, parameters); return true;