changeset 1590:ba0226474e22

New configuration option: "HttpTimeout" to set the default timeout for HTTP requests
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 26 Aug 2015 17:51:03 +0200
parents 334d3a92ed83
children cd9d99fe32e9
files Core/HttpClient.cpp Core/HttpClient.h NEWS OrthancServer/main.cpp Resources/Configuration.json
diffstat 5 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;
+  }
 }
--- 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);
   };
 }
--- 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
--- 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));
 
--- 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