Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPlugins.cpp @ 3413:f09bfdea3fc3
rename
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Jun 2019 14:02:57 +0200 |
parents | b7728227a852 |
children | b9cba6a91780 |
comparison
equal
deleted
inserted
replaced
3412:327bace7e98a | 3413:f09bfdea3fc3 |
---|---|
1028 } | 1028 } |
1029 }; | 1029 }; |
1030 | 1030 |
1031 | 1031 |
1032 | 1032 |
1033 class OrthancPlugins::StreamingHttpRequest : public HttpClient::IRequestBody | 1033 class OrthancPlugins::ChunkedHttpRequest : public HttpClient::IRequestBody |
1034 { | 1034 { |
1035 private: | 1035 private: |
1036 const _OrthancPluginStreamingHttpClient& params_; | 1036 const _OrthancPluginChunkedHttpClient& params_; |
1037 PluginsErrorDictionary& errorDictionary_; | 1037 PluginsErrorDictionary& errorDictionary_; |
1038 | 1038 |
1039 public: | 1039 public: |
1040 StreamingHttpRequest(const _OrthancPluginStreamingHttpClient& params, | 1040 ChunkedHttpRequest(const _OrthancPluginChunkedHttpClient& params, |
1041 PluginsErrorDictionary& errorDictionary) : | 1041 PluginsErrorDictionary& errorDictionary) : |
1042 params_(params), | 1042 params_(params), |
1043 errorDictionary_(errorDictionary) | 1043 errorDictionary_(errorDictionary) |
1044 { | 1044 { |
1045 } | 1045 } |
1076 } | 1076 } |
1077 } | 1077 } |
1078 }; | 1078 }; |
1079 | 1079 |
1080 | 1080 |
1081 class OrthancPlugins::StreamingHttpAnswer : public HttpClient::IAnswer | 1081 class OrthancPlugins::ChunkedHttpAnswer : public HttpClient::IAnswer |
1082 { | 1082 { |
1083 private: | 1083 private: |
1084 const _OrthancPluginStreamingHttpClient& params_; | 1084 const _OrthancPluginChunkedHttpClient& params_; |
1085 PluginsErrorDictionary& errorDictionary_; | 1085 PluginsErrorDictionary& errorDictionary_; |
1086 | 1086 |
1087 public: | 1087 public: |
1088 StreamingHttpAnswer(const _OrthancPluginStreamingHttpClient& params, | 1088 ChunkedHttpAnswer(const _OrthancPluginChunkedHttpClient& params, |
1089 PluginsErrorDictionary& errorDictionary) : | 1089 PluginsErrorDictionary& errorDictionary) : |
1090 params_(params), | 1090 params_(params), |
1091 errorDictionary_(errorDictionary) | 1091 errorDictionary_(errorDictionary) |
1092 { | 1092 { |
1093 } | 1093 } |
2289 throw OrthancException(ErrorCode_ParameterOutOfRange); | 2289 throw OrthancException(ErrorCode_ParameterOutOfRange); |
2290 } | 2290 } |
2291 } | 2291 } |
2292 | 2292 |
2293 | 2293 |
2294 static void ExecuteHttpClientWithoutStream(uint16_t& httpStatus, | 2294 static void ExecuteHttpClientWithoutChunkedBody(uint16_t& httpStatus, |
2295 OrthancPluginMemoryBuffer* answerBody, | 2295 OrthancPluginMemoryBuffer* answerBody, |
2296 OrthancPluginMemoryBuffer* answerHeaders, | 2296 OrthancPluginMemoryBuffer* answerHeaders, |
2297 HttpClient& client) | 2297 HttpClient& client) |
2298 { | 2298 { |
2299 if (answerBody == NULL) | 2299 if (answerBody == NULL) |
2300 { | 2300 { |
2301 throw OrthancException(ErrorCode_NullPointer); | 2301 throw OrthancException(ErrorCode_NullPointer); |
2302 } | 2302 } |
2367 | 2367 |
2368 SetupHttpClient(client, converted); | 2368 SetupHttpClient(client, converted); |
2369 } | 2369 } |
2370 | 2370 |
2371 uint16_t status; | 2371 uint16_t status; |
2372 ExecuteHttpClientWithoutStream(status, p.target, NULL, client); | 2372 ExecuteHttpClientWithoutChunkedBody(status, p.target, NULL, client); |
2373 } | 2373 } |
2374 | 2374 |
2375 | 2375 |
2376 void OrthancPlugins::CallHttpClient2(const void* parameters) | 2376 void OrthancPlugins::CallHttpClient2(const void* parameters) |
2377 { | 2377 { |
2389 { | 2389 { |
2390 client.GetBody().assign(reinterpret_cast<const char*>(p.body), p.bodySize); | 2390 client.GetBody().assign(reinterpret_cast<const char*>(p.body), p.bodySize); |
2391 } | 2391 } |
2392 | 2392 |
2393 SetupHttpClient(client, p); | 2393 SetupHttpClient(client, p); |
2394 ExecuteHttpClientWithoutStream(*p.httpStatus, p.answerBody, p.answerHeaders, client); | 2394 ExecuteHttpClientWithoutChunkedBody(*p.httpStatus, p.answerBody, p.answerHeaders, client); |
2395 } | 2395 } |
2396 | 2396 |
2397 | 2397 |
2398 void OrthancPlugins::StreamingHttpClient(const void* parameters) | 2398 void OrthancPlugins::ChunkedHttpClient(const void* parameters) |
2399 { | 2399 { |
2400 const _OrthancPluginStreamingHttpClient& p = | 2400 const _OrthancPluginChunkedHttpClient& p = |
2401 *reinterpret_cast<const _OrthancPluginStreamingHttpClient*>(parameters); | 2401 *reinterpret_cast<const _OrthancPluginChunkedHttpClient*>(parameters); |
2402 | 2402 |
2403 if (p.httpStatus == NULL) | 2403 if (p.httpStatus == NULL) |
2404 { | 2404 { |
2405 throw OrthancException(ErrorCode_NullPointer); | 2405 throw OrthancException(ErrorCode_NullPointer); |
2406 } | 2406 } |
2430 converted.pkcs11 = p.pkcs11; | 2430 converted.pkcs11 = p.pkcs11; |
2431 | 2431 |
2432 SetupHttpClient(client, converted); | 2432 SetupHttpClient(client, converted); |
2433 } | 2433 } |
2434 | 2434 |
2435 StreamingHttpRequest body(p, pimpl_->dictionary_); | 2435 ChunkedHttpRequest body(p, pimpl_->dictionary_); |
2436 client.SetBody(body); | 2436 client.SetBody(body); |
2437 | 2437 |
2438 StreamingHttpAnswer answer(p, pimpl_->dictionary_); | 2438 ChunkedHttpAnswer answer(p, pimpl_->dictionary_); |
2439 | 2439 |
2440 bool success = client.Apply(answer); | 2440 bool success = client.Apply(answer); |
2441 | 2441 |
2442 *p.httpStatus = static_cast<uint16_t>(client.GetLastStatus()); | 2442 *p.httpStatus = static_cast<uint16_t>(client.GetLastStatus()); |
2443 | 2443 |
3124 | 3124 |
3125 case _OrthancPluginService_CallHttpClient2: | 3125 case _OrthancPluginService_CallHttpClient2: |
3126 CallHttpClient2(parameters); | 3126 CallHttpClient2(parameters); |
3127 return true; | 3127 return true; |
3128 | 3128 |
3129 case _OrthancPluginService_StreamingHttpClient: | 3129 case _OrthancPluginService_ChunkedHttpClient: |
3130 StreamingHttpClient(parameters); | 3130 ChunkedHttpClient(parameters); |
3131 return true; | 3131 return true; |
3132 | 3132 |
3133 case _OrthancPluginService_ConvertPixelFormat: | 3133 case _OrthancPluginService_ConvertPixelFormat: |
3134 ConvertPixelFormat(parameters); | 3134 ConvertPixelFormat(parameters); |
3135 return true; | 3135 return true; |