comparison Plugins/Engine/OrthancPlugins.cpp @ 1571:3232f1c995a5

provide the origin of the requests to HTTP handlers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Aug 2015 11:04:19 +0200
parents 89ab71a68fcf
children 904096e7367e
comparison
equal deleted inserted replaced
1570:2bd2c280f9b5 1571:3232f1c995a5
227 } 227 }
228 } 228 }
229 229
230 230
231 bool OrthancPlugins::Handle(HttpOutput& output, 231 bool OrthancPlugins::Handle(HttpOutput& output,
232 RequestOrigin /*origin*/,
233 const char* /*remoteIp*/,
234 const char* /*username*/,
232 HttpMethod method, 235 HttpMethod method,
233 const UriComponents& uri, 236 const UriComponents& uri,
234 const Arguments& headers, 237 const Arguments& headers,
235 const GetArguments& getArguments, 238 const GetArguments& getArguments,
236 const char* bodyData, 239 const char* bodyData,
625 628
626 CheckContextAvailable(); 629 CheckContextAvailable();
627 IHttpHandler& handler = pimpl_->context_->GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins); 630 IHttpHandler& handler = pimpl_->context_->GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
628 631
629 std::string result; 632 std::string result;
630 if (HttpToolbox::SimpleGet(result, handler, p.uri)) 633 if (HttpToolbox::SimpleGet(result, handler, RequestOrigin_Plugins, p.uri))
631 { 634 {
632 CopyToMemoryBuffer(*p.target, result); 635 CopyToMemoryBuffer(*p.target, result);
633 } 636 }
634 else 637 else
635 { 638 {
651 CheckContextAvailable(); 654 CheckContextAvailable();
652 IHttpHandler& handler = pimpl_->context_->GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins); 655 IHttpHandler& handler = pimpl_->context_->GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
653 656
654 std::string result; 657 std::string result;
655 if (isPost ? 658 if (isPost ?
656 HttpToolbox::SimplePost(result, handler, p.uri, p.body, p.bodySize) : 659 HttpToolbox::SimplePost(result, handler, RequestOrigin_Plugins, p.uri, p.body, p.bodySize) :
657 HttpToolbox::SimplePut (result, handler, p.uri, p.body, p.bodySize)) 660 HttpToolbox::SimplePut (result, handler, RequestOrigin_Plugins, p.uri, p.body, p.bodySize))
658 { 661 {
659 CopyToMemoryBuffer(*p.target, result); 662 CopyToMemoryBuffer(*p.target, result);
660 } 663 }
661 else 664 else
662 { 665 {
673 << (afterPlugins ? " (after plugins)" : " (built-in API)"); 676 << (afterPlugins ? " (after plugins)" : " (built-in API)");
674 677
675 CheckContextAvailable(); 678 CheckContextAvailable();
676 IHttpHandler& handler = pimpl_->context_->GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins); 679 IHttpHandler& handler = pimpl_->context_->GetHttpHandler().RestrictToOrthancRestApi(!afterPlugins);
677 680
678 if (!HttpToolbox::SimpleDelete(handler, uri)) 681 if (!HttpToolbox::SimpleDelete(handler, RequestOrigin_Plugins, uri))
679 { 682 {
680 throw OrthancException(ErrorCode_BadRequest); 683 throw OrthancException(ErrorCode_BadRequest);
681 } 684 }
682 } 685 }
683 686