comparison Plugins/Engine/OrthancPlugins.cpp @ 1363:feaf2840917c

Plugins now receive duplicated GET arguments in their REST callbacks
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 May 2015 15:21:26 +0200
parents 7227b096a6dc
children d371a66972a4
comparison
equal deleted inserted replaced
1362:bf6db7d2f8b1 1363:feaf2840917c
301 pos++; 301 pos++;
302 } 302 }
303 } 303 }
304 304
305 305
306 static void ArgumentsToPlugin(std::vector<const char*>& keys,
307 std::vector<const char*>& values,
308 const HttpHandler::GetArguments& arguments)
309 {
310 keys.resize(arguments.size());
311 values.resize(arguments.size());
312
313 for (size_t i = 0; i < arguments.size(); i++)
314 {
315 keys[i] = arguments[i].first.c_str();
316 values[i] = arguments[i].second.c_str();
317 }
318 }
319
320
306 bool OrthancPlugins::Handle(HttpOutput& output, 321 bool OrthancPlugins::Handle(HttpOutput& output,
307 HttpMethod method, 322 HttpMethod method,
308 const UriComponents& uri, 323 const UriComponents& uri,
309 const Arguments& headers, 324 const Arguments& headers,
310 const Arguments& getArguments, 325 const GetArguments& getArguments,
311 const std::string& postData) 326 const std::string& postData)
312 { 327 {
313 std::string flatUri = Toolbox::FlattenUri(uri); 328 std::string flatUri = Toolbox::FlattenUri(uri);
314 OrthancPluginRestCallback callback = NULL; 329 OrthancPluginRestCallback callback = NULL;
315 330
669 684
670 HttpHandler::Arguments headers; // No HTTP header 685 HttpHandler::Arguments headers; // No HTTP header
671 std::string body; // No body for a GET request 686 std::string body; // No body for a GET request
672 687
673 UriComponents uri; 688 UriComponents uri;
674 HttpHandler::Arguments getArguments; 689 HttpHandler::GetArguments getArguments;
675 HttpHandler::ParseGetQuery(uri, getArguments, p.uri); 690 HttpHandler::ParseGetQuery(uri, getArguments, p.uri);
676 691
677 StringHttpOutput stream; 692 StringHttpOutput stream;
678 HttpOutput http(stream, false /* no keep alive */); 693 HttpOutput http(stream, false /* no keep alive */);
679 694
712 { 727 {
713 const _OrthancPluginRestApiPostPut& p = 728 const _OrthancPluginRestApiPostPut& p =
714 *reinterpret_cast<const _OrthancPluginRestApiPostPut*>(parameters); 729 *reinterpret_cast<const _OrthancPluginRestApiPostPut*>(parameters);
715 730
716 HttpHandler::Arguments headers; // No HTTP header 731 HttpHandler::Arguments headers; // No HTTP header
717 HttpHandler::Arguments getArguments; // No GET argument for POST/PUT 732 HttpHandler::GetArguments getArguments; // No GET argument for POST/PUT
718 733
719 UriComponents uri; 734 UriComponents uri;
720 Toolbox::SplitUriComponents(uri, p.uri); 735 Toolbox::SplitUriComponents(uri, p.uri);
721 736
722 // TODO Avoid unecessary memcpy 737 // TODO Avoid unecessary memcpy
761 // The "parameters" point to the URI 776 // The "parameters" point to the URI
762 UriComponents uri; 777 UriComponents uri;
763 Toolbox::SplitUriComponents(uri, reinterpret_cast<const char*>(parameters)); 778 Toolbox::SplitUriComponents(uri, reinterpret_cast<const char*>(parameters));
764 779
765 HttpHandler::Arguments headers; // No HTTP header 780 HttpHandler::Arguments headers; // No HTTP header
766 HttpHandler::Arguments getArguments; // No GET argument for POST/PUT 781 HttpHandler::GetArguments getArguments; // No GET argument for POST/PUT
767 std::string body; // No body for DELETE 782 std::string body; // No body for DELETE
768 783
769 StringHttpOutput stream; 784 StringHttpOutput stream;
770 HttpOutput http(stream, false /* no keep alive */); 785 HttpOutput http(stream, false /* no keep alive */);
771 786