Mercurial > hg > orthanc
comparison OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 4837:a678ff1b8278
CPP Wrapper: fail when trying to use body > 4GB
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 02 Dec 2021 13:00:27 +0100 |
parents | 365f51fae413 |
children | 8557729ebaa2 |
comparison
equal
deleted
inserted
replaced
4826:6c276fac0cc0 | 4837:a678ff1b8278 |
---|---|
537 const std::string& body, | 537 const std::string& body, |
538 const std::string& username, | 538 const std::string& username, |
539 const std::string& password) | 539 const std::string& password) |
540 { | 540 { |
541 Clear(); | 541 Clear(); |
542 | |
543 if (body.size() > 0xffffffffu) | |
544 { | |
545 LogError("Cannot handle body size > 4GB"); | |
546 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); | |
547 } | |
548 | |
542 return CheckHttp(OrthancPluginHttpPost(GetGlobalContext(), &buffer_, url.c_str(), | 549 return CheckHttp(OrthancPluginHttpPost(GetGlobalContext(), &buffer_, url.c_str(), |
543 body.c_str(), body.size(), | 550 body.c_str(), body.size(), |
544 username.empty() ? NULL : username.c_str(), | 551 username.empty() ? NULL : username.c_str(), |
545 password.empty() ? NULL : password.c_str())); | 552 password.empty() ? NULL : password.c_str())); |
546 } | 553 } |
550 const std::string& body, | 557 const std::string& body, |
551 const std::string& username, | 558 const std::string& username, |
552 const std::string& password) | 559 const std::string& password) |
553 { | 560 { |
554 Clear(); | 561 Clear(); |
562 | |
563 if (body.size() > 0xffffffffu) | |
564 { | |
565 LogError("Cannot handle body size > 4GB"); | |
566 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); | |
567 } | |
568 | |
555 return CheckHttp(OrthancPluginHttpPut(GetGlobalContext(), &buffer_, url.c_str(), | 569 return CheckHttp(OrthancPluginHttpPut(GetGlobalContext(), &buffer_, url.c_str(), |
556 body.empty() ? NULL : body.c_str(), | 570 body.empty() ? NULL : body.c_str(), |
557 body.size(), | 571 body.size(), |
558 username.empty() ? NULL : username.c_str(), | 572 username.empty() ? NULL : username.c_str(), |
559 password.empty() ? NULL : password.c_str())); | 573 password.empty() ? NULL : password.c_str())); |
1890 if (index >= index_.size()) | 1904 if (index >= index_.size()) |
1891 { | 1905 { |
1892 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); | 1906 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); |
1893 } | 1907 } |
1894 | 1908 |
1909 if (body.size() > 0xffffffffu) | |
1910 { | |
1911 LogError("Cannot handle body size > 4GB"); | |
1912 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); | |
1913 } | |
1914 | |
1895 OrthancPlugins::MemoryBuffer answer; | 1915 OrthancPlugins::MemoryBuffer answer; |
1896 uint16_t status; | 1916 uint16_t status; |
1897 OrthancPluginErrorCode code = OrthancPluginCallPeerApi | 1917 OrthancPluginErrorCode code = OrthancPluginCallPeerApi |
1898 (GetGlobalContext(), *answer, NULL, &status, peers_, | 1918 (GetGlobalContext(), *answer, NULL, &status, peers_, |
1899 static_cast<uint32_t>(index), OrthancPluginHttpMethod_Post, uri.c_str(), | 1919 static_cast<uint32_t>(index), OrthancPluginHttpMethod_Post, uri.c_str(), |
1916 const std::string& body) const | 1936 const std::string& body) const |
1917 { | 1937 { |
1918 if (index >= index_.size()) | 1938 if (index >= index_.size()) |
1919 { | 1939 { |
1920 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); | 1940 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); |
1941 } | |
1942 | |
1943 if (body.size() > 0xffffffffu) | |
1944 { | |
1945 LogError("Cannot handle body size > 4GB"); | |
1946 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); | |
1921 } | 1947 } |
1922 | 1948 |
1923 OrthancPlugins::MemoryBuffer answer; | 1949 OrthancPlugins::MemoryBuffer answer; |
1924 uint16_t status; | 1950 uint16_t status; |
1925 OrthancPluginErrorCode code = OrthancPluginCallPeerApi | 1951 OrthancPluginErrorCode code = OrthancPluginCallPeerApi |
2881 { | 2907 { |
2882 HeadersWrapper headers(headers_); | 2908 HeadersWrapper headers(headers_); |
2883 | 2909 |
2884 MemoryBuffer answerBodyBuffer, answerHeadersBuffer; | 2910 MemoryBuffer answerBodyBuffer, answerHeadersBuffer; |
2885 | 2911 |
2912 if (body.size() > 0xffffffffu) | |
2913 { | |
2914 LogError("Cannot handle body size > 4GB"); | |
2915 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); | |
2916 } | |
2917 | |
2886 OrthancPluginErrorCode error = OrthancPluginHttpClient( | 2918 OrthancPluginErrorCode error = OrthancPluginHttpClient( |
2887 GetGlobalContext(), | 2919 GetGlobalContext(), |
2888 *answerBodyBuffer, | 2920 *answerBodyBuffer, |
2889 *answerHeadersBuffer, | 2921 *answerHeadersBuffer, |
2890 &httpStatus, | 2922 &httpStatus, |