Mercurial > hg > orthanc
changeset 1273:88010d8e12cf
Support of HTTP proxy
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 19 Jan 2015 16:08:58 +0100 |
parents | 7442097b41c9 |
children | b9e2ed59cae4 |
files | Core/HttpClient.cpp Core/HttpClient.h Core/Lua/LuaContext.h NEWS OrthancServer/Scheduler/StorePeerCommand.cpp OrthancServer/ServerContext.cpp Resources/CMake/LibCurlConfiguration.cmake Resources/Configuration.json |
diffstat | 8 files changed, 26 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/HttpClient.cpp Mon Jan 12 17:42:29 2015 +0100 +++ b/Core/HttpClient.cpp Mon Jan 19 16:08:58 2015 +0100 @@ -171,6 +171,7 @@ CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_CUSTOMREQUEST, NULL)); CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_POSTFIELDS, NULL)); CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_POSTFIELDSIZE, 0)); + CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_PROXY, NULL)); // Set timeouts if (timeout_ <= 0) @@ -189,6 +190,11 @@ CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_USERPWD, credentials_.c_str())); } + if (proxy_.size() != 0) + { + CheckCode(curl_easy_setopt(pimpl_->curl_, CURLOPT_PROXY, proxy_.c_str())); + } + switch (method_) { case HttpMethod_Get:
--- a/Core/HttpClient.h Mon Jan 12 17:42:29 2015 +0100 +++ b/Core/HttpClient.h Mon Jan 19 16:08:58 2015 +0100 @@ -53,6 +53,7 @@ std::string postData_; bool isVerbose_; long timeout_; + std::string proxy_; void Setup(); @@ -134,6 +135,11 @@ void SetCredentials(const char* username, const char* password); + void SetProxy(const std::string& proxy) + { + proxy_ = proxy; + } + static void GlobalInitialize(); static void GlobalFinalize();
--- a/Core/Lua/LuaContext.h Mon Jan 12 17:42:29 2015 +0100 +++ b/Core/Lua/LuaContext.h Mon Jan 19 16:08:58 2015 +0100 @@ -102,5 +102,10 @@ { httpClient_.SetCredentials(username, password); } + + void SetHttpProxy(const std::string& proxy) + { + httpClient_.SetProxy(proxy); + } }; }
--- a/NEWS Mon Jan 12 17:42:29 2015 +0100 +++ b/NEWS Mon Jan 19 16:08:58 2015 +0100 @@ -4,6 +4,7 @@ General ------- +* Support of HTTP proxy * Instances without PatientID are now allowed * Support of Tudor DICOM in Query/Retrieve * Fix issue 25 (AET with underscore not allowed)
--- a/OrthancServer/Scheduler/StorePeerCommand.cpp Mon Jan 12 17:42:29 2015 +0100 +++ b/OrthancServer/Scheduler/StorePeerCommand.cpp Mon Jan 19 16:08:58 2015 +0100 @@ -52,6 +52,7 @@ { // Configure the HTTP client HttpClient client; + client.SetProxy(Configuration::GetGlobalStringParameter("HttpProxy", "")); if (peer_.GetUsername().size() != 0 && peer_.GetPassword().size() != 0) {
--- a/OrthancServer/ServerContext.cpp Mon Jan 12 17:42:29 2015 +0100 +++ b/OrthancServer/ServerContext.cpp Mon Jan 19 16:08:58 2015 +0100 @@ -84,6 +84,7 @@ //scu_.SetMillisecondsBeforeClose(1); // The connection is always released lua_.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX); + lua_.SetHttpProxy(Configuration::GetGlobalStringParameter("HttpProxy", "")); } void ServerContext::SetCompressionEnabled(bool enabled)
--- a/Resources/CMake/LibCurlConfiguration.cmake Mon Jan 12 17:42:29 2015 +0100 +++ b/Resources/CMake/LibCurlConfiguration.cmake Mon Jan 19 16:08:58 2015 +0100 @@ -26,7 +26,7 @@ -DCURL_DISABLE_LDAP=1 -DCURL_DISABLE_LDAPS=1 -DCURL_DISABLE_POP3=1 - -DCURL_DISABLE_PROXY=1 + #-DCURL_DISABLE_PROXY=1 -DCURL_DISABLE_RTSP=1 -DCURL_DISABLE_TELNET=1 -DCURL_DISABLE_TFTP=1
--- a/Resources/Configuration.json Mon Jan 12 17:42:29 2015 +0100 +++ b/Resources/Configuration.json Mon Jan 19 16:08:58 2015 +0100 @@ -140,6 +140,11 @@ // "peer2" : [ "http://localhost:8044/" ] }, + // Parameters of the HTTP proxy to be used by Orthanc. If set to the + // empty string, no HTTP proxy is used. For instance: + // "HttpProxy" : "192.168.0.1:3128" + // "HttpProxy" : "proxyUser:proxyPassword@192.168.0.1:3128" + "HttpProxy" : "", /**