Mercurial > hg > orthanc-python
comparison Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp @ 100:e2b2e1d4e1bb
fixed compatibility with Orthanc SDK 1.8.1
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Feb 2022 07:30:33 +0100 |
parents | 07fdf388c12e |
children | 5a60cbbe9bb0 |
comparison
equal
deleted
inserted
replaced
99:465bf098554b | 100:e2b2e1d4e1bb |
---|---|
1 /** | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
4 * Department, University Hospital of Liege, Belgium | 4 * Department, University Hospital of Liege, Belgium |
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium | 5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
6 * | 7 * |
7 * This program is free software: you can redistribute it and/or | 8 * This program is free software: you can redistribute it and/or |
8 * modify it under the terms of the GNU General Public License as | 9 * modify it under the terms of the GNU General Public License as |
9 * published by the Free Software Foundation, either version 3 of the | 10 * published by the Free Software Foundation, either version 3 of the |
10 * License, or (at your option) any later version. | 11 * License, or (at your option) any later version. |
537 const std::string& body, | 538 const std::string& body, |
538 const std::string& username, | 539 const std::string& username, |
539 const std::string& password) | 540 const std::string& password) |
540 { | 541 { |
541 Clear(); | 542 Clear(); |
543 | |
544 if (body.size() > 0xffffffffu) | |
545 { | |
546 LogError("Cannot handle body size > 4GB"); | |
547 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); | |
548 } | |
549 | |
542 return CheckHttp(OrthancPluginHttpPost(GetGlobalContext(), &buffer_, url.c_str(), | 550 return CheckHttp(OrthancPluginHttpPost(GetGlobalContext(), &buffer_, url.c_str(), |
543 body.c_str(), body.size(), | 551 body.c_str(), body.size(), |
544 username.empty() ? NULL : username.c_str(), | 552 username.empty() ? NULL : username.c_str(), |
545 password.empty() ? NULL : password.c_str())); | 553 password.empty() ? NULL : password.c_str())); |
546 } | 554 } |
550 const std::string& body, | 558 const std::string& body, |
551 const std::string& username, | 559 const std::string& username, |
552 const std::string& password) | 560 const std::string& password) |
553 { | 561 { |
554 Clear(); | 562 Clear(); |
563 | |
564 if (body.size() > 0xffffffffu) | |
565 { | |
566 LogError("Cannot handle body size > 4GB"); | |
567 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); | |
568 } | |
569 | |
555 return CheckHttp(OrthancPluginHttpPut(GetGlobalContext(), &buffer_, url.c_str(), | 570 return CheckHttp(OrthancPluginHttpPut(GetGlobalContext(), &buffer_, url.c_str(), |
556 body.empty() ? NULL : body.c_str(), | 571 body.empty() ? NULL : body.c_str(), |
557 body.size(), | 572 body.size(), |
558 username.empty() ? NULL : username.c_str(), | 573 username.empty() ? NULL : username.c_str(), |
559 password.empty() ? NULL : password.c_str())); | 574 password.empty() ? NULL : password.c_str())); |
1890 if (index >= index_.size()) | 1905 if (index >= index_.size()) |
1891 { | 1906 { |
1892 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); | 1907 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); |
1893 } | 1908 } |
1894 | 1909 |
1910 if (body.size() > 0xffffffffu) | |
1911 { | |
1912 LogError("Cannot handle body size > 4GB"); | |
1913 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); | |
1914 } | |
1915 | |
1895 OrthancPlugins::MemoryBuffer answer; | 1916 OrthancPlugins::MemoryBuffer answer; |
1896 uint16_t status; | 1917 uint16_t status; |
1897 OrthancPluginErrorCode code = OrthancPluginCallPeerApi | 1918 OrthancPluginErrorCode code = OrthancPluginCallPeerApi |
1898 (GetGlobalContext(), *answer, NULL, &status, peers_, | 1919 (GetGlobalContext(), *answer, NULL, &status, peers_, |
1899 static_cast<uint32_t>(index), OrthancPluginHttpMethod_Post, uri.c_str(), | 1920 static_cast<uint32_t>(index), OrthancPluginHttpMethod_Post, uri.c_str(), |
1916 const std::string& body) const | 1937 const std::string& body) const |
1917 { | 1938 { |
1918 if (index >= index_.size()) | 1939 if (index >= index_.size()) |
1919 { | 1940 { |
1920 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); | 1941 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); |
1942 } | |
1943 | |
1944 if (body.size() > 0xffffffffu) | |
1945 { | |
1946 LogError("Cannot handle body size > 4GB"); | |
1947 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); | |
1921 } | 1948 } |
1922 | 1949 |
1923 OrthancPlugins::MemoryBuffer answer; | 1950 OrthancPlugins::MemoryBuffer answer; |
1924 uint16_t status; | 1951 uint16_t status; |
1925 OrthancPluginErrorCode code = OrthancPluginCallPeerApi | 1952 OrthancPluginErrorCode code = OrthancPluginCallPeerApi |
2567 } | 2594 } |
2568 | 2595 |
2569 | 2596 |
2570 void HttpClient::ClearCredentials() | 2597 void HttpClient::ClearCredentials() |
2571 { | 2598 { |
2572 username_.empty(); | 2599 username_.clear(); |
2573 password_.empty(); | 2600 password_.clear(); |
2574 } | 2601 } |
2575 | 2602 |
2576 | 2603 |
2577 void HttpClient::SetCertificate(const std::string& certificateFile, | 2604 void HttpClient::SetCertificate(const std::string& certificateFile, |
2578 const std::string& keyFile, | 2605 const std::string& keyFile, |
2881 { | 2908 { |
2882 HeadersWrapper headers(headers_); | 2909 HeadersWrapper headers(headers_); |
2883 | 2910 |
2884 MemoryBuffer answerBodyBuffer, answerHeadersBuffer; | 2911 MemoryBuffer answerBodyBuffer, answerHeadersBuffer; |
2885 | 2912 |
2913 if (body.size() > 0xffffffffu) | |
2914 { | |
2915 LogError("Cannot handle body size > 4GB"); | |
2916 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); | |
2917 } | |
2918 | |
2886 OrthancPluginErrorCode error = OrthancPluginHttpClient( | 2919 OrthancPluginErrorCode error = OrthancPluginHttpClient( |
2887 GetGlobalContext(), | 2920 GetGlobalContext(), |
2888 *answerBodyBuffer, | 2921 *answerBodyBuffer, |
2889 *answerHeadersBuffer, | 2922 *answerHeadersBuffer, |
2890 &httpStatus, | 2923 &httpStatus, |