comparison Plugins/Engine/OrthancPlugins.cpp @ 1441:f3672356c121

refactoring: IHttpHandler and HttpToolbox
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 01 Jul 2015 10:38:39 +0200
parents 02f5a3f5c0a0
children d26c8a93d05a
comparison
equal deleted inserted replaced
1440:3567503c00a7 1441:f3672356c121
193 } 193 }
194 194
195 195
196 static void ArgumentsToPlugin(std::vector<const char*>& keys, 196 static void ArgumentsToPlugin(std::vector<const char*>& keys,
197 std::vector<const char*>& values, 197 std::vector<const char*>& values,
198 const HttpHandler::Arguments& arguments) 198 const IHttpHandler::Arguments& arguments)
199 { 199 {
200 keys.resize(arguments.size()); 200 keys.resize(arguments.size());
201 values.resize(arguments.size()); 201 values.resize(arguments.size());
202 202
203 size_t pos = 0; 203 size_t pos = 0;
204 for (HttpHandler::Arguments::const_iterator 204 for (IHttpHandler::Arguments::const_iterator
205 it = arguments.begin(); it != arguments.end(); ++it) 205 it = arguments.begin(); it != arguments.end(); ++it)
206 { 206 {
207 keys[pos] = it->first.c_str(); 207 keys[pos] = it->first.c_str();
208 values[pos] = it->second.c_str(); 208 values[pos] = it->second.c_str();
209 pos++; 209 pos++;
211 } 211 }
212 212
213 213
214 static void ArgumentsToPlugin(std::vector<const char*>& keys, 214 static void ArgumentsToPlugin(std::vector<const char*>& keys,
215 std::vector<const char*>& values, 215 std::vector<const char*>& values,
216 const HttpHandler::GetArguments& arguments) 216 const IHttpHandler::GetArguments& arguments)
217 { 217 {
218 keys.resize(arguments.size()); 218 keys.resize(arguments.size());
219 values.resize(arguments.size()); 219 values.resize(arguments.size());
220 220
221 for (size_t i = 0; i < arguments.size(); i++) 221 for (size_t i = 0; i < arguments.size(); i++)
614 bool afterPlugins) 614 bool afterPlugins)
615 { 615 {
616 const _OrthancPluginRestApiGet& p = 616 const _OrthancPluginRestApiGet& p =
617 *reinterpret_cast<const _OrthancPluginRestApiGet*>(parameters); 617 *reinterpret_cast<const _OrthancPluginRestApiGet*>(parameters);
618 618
619 // TODO : Use "HttpHandler::SimpleGet()" 619 // TODO : Use "HttpToolbox::SimpleGet()"
620 620
621 HttpHandler::Arguments headers; // No HTTP header 621 IHttpHandler::Arguments headers; // No HTTP header
622 std::string body; // No body for a GET request 622 std::string body; // No body for a GET request
623 623
624 UriComponents uri; 624 UriComponents uri;
625 HttpHandler::GetArguments getArguments; 625 IHttpHandler::GetArguments getArguments;
626 HttpHandler::ParseGetQuery(uri, getArguments, p.uri); 626 HttpToolbox::ParseGetQuery(uri, getArguments, p.uri);
627 627
628 StringHttpOutput stream; 628 StringHttpOutput stream;
629 HttpOutput http(stream, false /* no keep alive */); 629 HttpOutput http(stream, false /* no keep alive */);
630 630
631 LOG(INFO) << "Plugin making REST GET call on URI " << p.uri 631 LOG(INFO) << "Plugin making REST GET call on URI " << p.uri
662 bool afterPlugins) 662 bool afterPlugins)
663 { 663 {
664 const _OrthancPluginRestApiPostPut& p = 664 const _OrthancPluginRestApiPostPut& p =
665 *reinterpret_cast<const _OrthancPluginRestApiPostPut*>(parameters); 665 *reinterpret_cast<const _OrthancPluginRestApiPostPut*>(parameters);
666 666
667 HttpHandler::Arguments headers; // No HTTP header 667 IHttpHandler::Arguments headers; // No HTTP header
668 HttpHandler::GetArguments getArguments; // No GET argument for POST/PUT 668 IHttpHandler::GetArguments getArguments; // No GET argument for POST/PUT
669 669
670 UriComponents uri; 670 UriComponents uri;
671 Toolbox::SplitUriComponents(uri, p.uri); 671 Toolbox::SplitUriComponents(uri, p.uri);
672 672
673 // TODO Avoid unecessary memcpy 673 // TODO Avoid unecessary memcpy
711 { 711 {
712 // The "parameters" point to the URI 712 // The "parameters" point to the URI
713 UriComponents uri; 713 UriComponents uri;
714 Toolbox::SplitUriComponents(uri, reinterpret_cast<const char*>(parameters)); 714 Toolbox::SplitUriComponents(uri, reinterpret_cast<const char*>(parameters));
715 715
716 HttpHandler::Arguments headers; // No HTTP header 716 IHttpHandler::Arguments headers; // No HTTP header
717 HttpHandler::GetArguments getArguments; // No GET argument for POST/PUT 717 IHttpHandler::GetArguments getArguments; // No GET argument for POST/PUT
718 std::string body; // No body for DELETE 718 std::string body; // No body for DELETE
719 719
720 StringHttpOutput stream; 720 StringHttpOutput stream;
721 HttpOutput http(stream, false /* no keep alive */); 721 HttpOutput http(stream, false /* no keep alive */);
722 722