# HG changeset patch # User Sebastien Jodogne # Date 1440604263 -7200 # Node ID ba0226474e2265acaddf485a84170fe1d4ccb25f # Parent 334d3a92ed83ee824fa47690cf87e750cef85400 New configuration option: "HttpTimeout" to set the default timeout for HTTP requests diff -r 334d3a92ed83 -r ba0226474e22 Core/HttpClient.cpp --- a/Core/HttpClient.cpp Wed Aug 26 17:43:00 2015 +0200 +++ b/Core/HttpClient.cpp Wed Aug 26 17:51:03 2015 +0200 @@ -44,6 +44,7 @@ static std::string globalCACertificates_; static bool globalVerifyPeers_ = true; +static long globalTimeout_ = 0; extern "C" { @@ -140,7 +141,7 @@ method_ = HttpMethod_Get; lastStatus_ = HttpStatus_200_Ok; isVerbose_ = false; - timeout_ = 0; + timeout_ = globalTimeout_; verifyPeers_ = globalVerifyPeers_; } @@ -384,4 +385,11 @@ { curl_global_cleanup(); } + + + void HttpClient::SetDefaultTimeout(long timeout) + { + LOG(INFO) << "Setting the default timeout for HTTP client connections: " << timeout << " seconds"; + globalTimeout_ = timeout; + } } diff -r 334d3a92ed83 -r ba0226474e22 Core/HttpClient.h --- a/Core/HttpClient.h Wed Aug 26 17:43:00 2015 +0200 +++ b/Core/HttpClient.h Wed Aug 26 17:51:03 2015 +0200 @@ -163,5 +163,7 @@ const std::string& httpsCACertificates); static void GlobalFinalize(); + + static void SetDefaultTimeout(long timeout); }; } diff -r 334d3a92ed83 -r ba0226474e22 NEWS --- a/NEWS Wed Aug 26 17:43:00 2015 +0200 +++ b/NEWS Wed Aug 26 17:51:03 2015 +0200 @@ -27,6 +27,7 @@ Maintenance ----------- +* New configuration option: "HttpTimeout" to set the default timeout for HTTP requests * Improved error codes * Many code refactorings * If error while calling the REST API, the answer body contains an error description diff -r 334d3a92ed83 -r ba0226474e22 OrthancServer/main.cpp --- a/OrthancServer/main.cpp Wed Aug 26 17:43:00 2015 +0200 +++ b/OrthancServer/main.cpp Wed Aug 26 17:51:03 2015 +0200 @@ -524,6 +524,7 @@ { ServerContext context(database, storageArea); + HttpClient::SetDefaultTimeout(Configuration::GetGlobalIntegerParameter("HttpTimeout", 0)); context.SetCompressionEnabled(Configuration::GetGlobalBoolParameter("StorageCompression", false)); context.SetStoreMD5ForAttachments(Configuration::GetGlobalBoolParameter("StoreMD5ForAttachments", true)); diff -r 334d3a92ed83 -r ba0226474e22 Resources/Configuration.json --- a/Resources/Configuration.json Wed Aug 26 17:43:00 2015 +0200 +++ b/Resources/Configuration.json Wed Aug 26 17:51:03 2015 +0200 @@ -146,6 +146,10 @@ // "HttpProxy" : "proxyUser:proxyPassword@192.168.0.1:3128" "HttpProxy" : "", + // Set the timeout for HTTP requests issued by Orthanc (in seconds). + "HttpTimeout" : 10, + + /** * Advanced options