Mercurial > hg > orthanc
changeset 3432:297ad330900c
merge
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Mon, 17 Jun 2019 23:37:07 +0200 |
parents | e0841192d7d0 (current diff) 954d15f24366 (diff) |
children | caa526bb65cc |
files | |
diffstat | 11 files changed, 102 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/HttpClient.cpp Mon Jun 17 23:36:37 2019 +0200 +++ b/Core/HttpClient.cpp Mon Jun 17 23:37:07 2019 +0200 @@ -46,6 +46,10 @@ #include <boost/thread/mutex.hpp> +// Default timeout = 60 seconds (in Orthanc <= 1.5.6, it was 10 seconds) +static const unsigned int DEFAULT_HTTP_TIMEOUT = 60; + + #if ORTHANC_ENABLE_PKCS11 == 1 # include "Pkcs11.h" #endif @@ -818,8 +822,8 @@ // Set timeouts if (timeout_ <= 0) { - CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_TIMEOUT, 10)); /* default: 10 seconds */ - CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_CONNECTTIMEOUT, 10)); /* default: 10 seconds */ + CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_TIMEOUT, DEFAULT_HTTP_TIMEOUT)); + CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_CONNECTTIMEOUT, DEFAULT_HTTP_TIMEOUT)); } else {
--- a/Core/HttpServer/HttpOutput.cpp Mon Jun 17 23:36:37 2019 +0200 +++ b/Core/HttpServer/HttpOutput.cpp Mon Jun 17 23:37:07 2019 +0200 @@ -306,7 +306,7 @@ size_t messageSize) { if (status == HttpStatus_301_MovedPermanently || - status == HttpStatus_401_Unauthorized || + //status == HttpStatus_401_Unauthorized || status == HttpStatus_405_MethodNotAllowed) { throw OrthancException(ErrorCode_ParameterOutOfRange,
--- a/NEWS Mon Jun 17 23:36:37 2019 +0200 +++ b/NEWS Mon Jun 17 23:37:07 2019 +0200 @@ -15,6 +15,7 @@ * New functions in the SDK: - OrthancPluginHttpClientChunkedBody(): HTTP client for POST/PUT with a chunked body - OrthancPluginRegisterMultipartRestCallback(): HTTP server for POST/PUT with multipart body + - OrthancPluginGetTagName(): Retrieve the name of a DICOM tag from its group and element Maintenance ----------- @@ -24,6 +25,7 @@ * Anonymization: Preserve hierarchical relationships in (0008,1115) [] (0020,000e) * Allow the serialization of signed 16bpp images in PAM format * HTTP header "Accept-Encoding" is honored for streams without built-in support for compression +* The default HTTP timeout is now 60 seconds (instead of 10 seconds in previous versions) * Fix issue #136 (C-FIND request fails when found DICOM file does not have certain tags) * Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any) * Fix issue #138 (POST to modalities/{name} accepts invalid characters)
--- a/OrthancServer/main.cpp Mon Jun 17 23:36:37 2019 +0200 +++ b/OrthancServer/main.cpp Mon Jun 17 23:37:07 2019 +0200 @@ -1117,7 +1117,11 @@ lock.GetConfiguration().InterpretStringParameterAsPath (lock.GetConfiguration().GetStringParameter("HttpsCACertificates", ""))); HttpClient::SetDefaultVerbose(lock.GetConfiguration().GetBooleanParameter("HttpVerbose", false)); + + // The value "0" below makes the class HttpClient use its default + // value (DEFAULT_HTTP_TIMEOUT = 60 seconds in Orthanc 1.5.7) HttpClient::SetDefaultTimeout(lock.GetConfiguration().GetUnsignedIntegerParameter("HttpTimeout", 0)); + HttpClient::SetDefaultProxy(lock.GetConfiguration().GetStringParameter("HttpProxy", "")); DicomUserConnection::SetDefaultTimeout(lock.GetConfiguration().GetUnsignedIntegerParameter("DicomScuTimeout", 10));
--- a/Plugins/Engine/OrthancPlugins.cpp Mon Jun 17 23:36:37 2019 +0200 +++ b/Plugins/Engine/OrthancPlugins.cpp Mon Jun 17 23:37:07 2019 +0200 @@ -2842,6 +2842,23 @@ } + void OrthancPlugins::GetTagName(const void* parameters) + { + const _OrthancPluginGetTagName& p = + *reinterpret_cast<const _OrthancPluginGetTagName*>(parameters); + + std::string privateCreator; + + if (p.privateCreator != NULL) + { + privateCreator = p.privateCreator; + } + + DicomTag tag(p.group, p.element); + *p.result = CopyString(FromDcmtkBridge::GetTagName(tag, privateCreator)); + } + + void OrthancPlugins::ApplyCreateImage(_OrthancPluginService service, const void* parameters) { @@ -3677,6 +3694,10 @@ return true; } + case _OrthancPluginService_GetTagName: + GetTagName(parameters); + return true; + default: return false; }
--- a/Plugins/Engine/OrthancPlugins.h Mon Jun 17 23:36:37 2019 +0200 +++ b/Plugins/Engine/OrthancPlugins.h Mon Jun 17 23:37:07 2019 +0200 @@ -203,6 +203,8 @@ void ComputeHash(_OrthancPluginService service, const void* parameters); + void GetTagName(const void* parameters); + void SignalChangeInternal(OrthancPluginChangeType changeType, OrthancPluginResourceType resourceType, const char* resource);
--- a/Plugins/Include/orthanc/OrthancCPlugin.h Mon Jun 17 23:36:37 2019 +0200 +++ b/Plugins/Include/orthanc/OrthancCPlugin.h Mon Jun 17 23:37:07 2019 +0200 @@ -113,9 +113,11 @@ #include <string.h> #ifdef WIN32 -#define ORTHANC_PLUGINS_API __declspec(dllexport) +# define ORTHANC_PLUGINS_API __declspec(dllexport) +#elif __GNUC__ >= 4 +# define ORTHANC_PLUGINS_API __attribute__ ((visibility ("default"))) #else -#define ORTHANC_PLUGINS_API +# define ORTHANC_PLUGINS_API #endif #define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 1 @@ -431,6 +433,7 @@ _OrthancPluginService_EncodeDicomWebJson = 32, _OrthancPluginService_EncodeDicomWebXml = 33, _OrthancPluginService_ChunkedHttpClient = 34, /* New in Orthanc 1.5.7 */ + _OrthancPluginService_GetTagName = 35, /* New in Orthanc 1.5.7 */ /* Registration of callbacks */ _OrthancPluginService_RegisterRestCallback = 1000, @@ -6966,6 +6969,45 @@ context->InvokeService(context, _OrthancPluginService_RegisterChunkedRestCallback, ¶ms); } + + + + + typedef struct + { + char** result; + uint16_t group; + uint16_t element; + const char* privateCreator; + } _OrthancPluginGetTagName; + + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetTagName( + OrthancPluginContext* context, + uint16_t group, + uint16_t element, + const char* privateCreator /* can be NULL */) + { + char* result; + + _OrthancPluginGetTagName params; + params.result = &result; + params.group = group; + params.element = element; + params.privateCreator = privateCreator; + + if (context->InvokeService(context, _OrthancPluginService_GetTagName, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + #ifdef __cplusplus } #endif
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Mon Jun 17 23:36:37 2019 +0200 +++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Mon Jun 17 23:37:07 2019 +0200 @@ -1298,7 +1298,7 @@ } else { - if (!answer.IsEmpty()) // i.e, on a PUT to metadata/..., orthand returns an empty response + if (!answer.IsEmpty()) // i.e, on a PUT to metadata/..., orthanc returns an empty response { answer.ToJson(result); } @@ -2222,6 +2222,16 @@ { } + + void HttpClient::AddHeaders(const HttpHeaders& headers) + { + for (HttpHeaders::const_iterator it = headers.begin(); + it != headers.end(); ++it) + { + headers_[it->first] = it->second; + } + } + void HttpClient::SetCredentials(const std::string& username, const std::string& password)
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.h Mon Jun 17 23:36:37 2019 +0200 +++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.h Mon Jun 17 23:37:07 2019 +0200 @@ -878,12 +878,19 @@ url_ = url; } + void SetHeaders(const HttpHeaders& headers) + { + headers_ = headers; + } + void AddHeader(const std::string& key, const std::string& value) { headers_[key] = value; } + void AddHeaders(const HttpHeaders& headers); + void SetCredentials(const std::string& username, const std::string& password);
--- a/Resources/CMake/DownloadPackage.cmake Mon Jun 17 23:36:37 2019 +0200 +++ b/Resources/CMake/DownloadPackage.cmake Mon Jun 17 23:37:07 2019 +0200 @@ -222,7 +222,9 @@ if ("${TMP_EXTENSION}" STREQUAL "gz") execute_process( - COMMAND ${ZIP_EXECUTABLE} e -y ${TMP_PATH} + # "-so" writes uncompressed file to stdout + COMMAND ${ZIP_EXECUTABLE} e -so -y ${TMP_PATH} + OUTPUT_FILE "${TargetFile}" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} RESULT_VARIABLE Failure OUTPUT_QUIET
--- a/Resources/Configuration.json Mon Jun 17 23:36:37 2019 +0200 +++ b/Resources/Configuration.json Mon Jun 17 23:37:07 2019 +0200 @@ -284,7 +284,7 @@ "HttpVerbose" : false, // Set the timeout for HTTP requests issued by Orthanc (in seconds). - "HttpTimeout" : 10, + "HttpTimeout" : 60, // Enable the verification of the peers during HTTPS requests. This // option must be set to "false" if using self-signed certificates.