diff options
-rw-r--r-- | kit/Kit.cpp | 1 | ||||
-rw-r--r-- | loolwsd.xml.in | 1 | ||||
-rw-r--r-- | wsd/LOOLWSD.cpp | 1 | ||||
-rw-r--r-- | wsd/Storage.cpp | 8 | ||||
-rw-r--r-- | wsd/Storage.hpp | 10 |
5 files changed, 18 insertions, 3 deletions
diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 2ad1c545a..42af4b531 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -43,7 +43,6 @@ #include <Poco/Exception.h> #include <Poco/JSON/Object.h> #include <Poco/JSON/Parser.h> -#include <Poco/Net/HTTPClientSession.h> #include <Poco/Net/HTTPRequest.h> #include <Poco/Net/HTTPResponse.h> #include <Poco/Net/NetException.h> diff --git a/loolwsd.xml.in b/loolwsd.xml.in index ceb78992e..f1235d618 100644 --- a/loolwsd.xml.in +++ b/loolwsd.xml.in @@ -99,6 +99,7 @@ <host desc="Ditto, but as IPv4-mapped IPv6 addresses">::ffff:172\.17\.[0-9]{1,3}\.[0-9]{1,3}</host> </post_allow> <frame_ancestors desc="Specify who is allowed to embed the LO Online iframe (loolwsd and WOPI host are always allowed). Separate multiple hosts by space."></frame_ancestors> + <connection_timeout_secs desc="Specifies the connection, send, recv timeout in seconds for connections initiated by loolwsd (such as WOPI connections)." type="int" default="30"></connection_timeout_secs> </net> <ssl desc="SSL settings"> diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 3756db0fb..806c22a0d 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -928,6 +928,7 @@ void LOOLWSD::initialize(Application& self) { "loleaflet_html", "loleaflet.html" }, { "loleaflet_logging", "false" }, { "mount_jail_tree", "true" }, + { "net.connection_timeout_secs", "30" }, { "net.listen", "any" }, { "net.proto", "all" }, { "net.service_root", "" }, diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp index 08a974d0d..9e3854d99 100644 --- a/wsd/Storage.cpp +++ b/wsd/Storage.cpp @@ -422,10 +422,16 @@ Poco::Net::HTTPClientSession* StorageBase::getHTTPClientSession(const Poco::URI& // We decoupled the Wopi communication from client communication because // the Wopi communication must have an independent policy. // So, we will use here only Storage settings. - return useSSL + Poco::Net::HTTPClientSession* session = useSSL ? new Poco::Net::HTTPSClientSession(uri.getHost(), uri.getPort(), Poco::Net::SSLManager::instance().defaultClientContext()) : new Poco::Net::HTTPClientSession(uri.getHost(), uri.getPort()); + + // Set the timeout to the configured value. + static int timeoutSec = LOOLWSD::getConfigValue<int>("net.connection_timeout_secs", 30); + session->setTimeout(Poco::Timespan(timeoutSec, 0)); + + return session; } namespace diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp index df1b59e5e..652b9bb17 100644 --- a/wsd/Storage.hpp +++ b/wsd/Storage.hpp @@ -17,7 +17,6 @@ #include <Poco/URI.h> #include <Poco/Util/Application.h> -#include <Poco/Net/HTTPClientSession.h> #include <Poco/JSON/Object.h> #include "Auth.hpp" @@ -26,6 +25,15 @@ #include "Util.hpp" #include <common/Authorization.hpp> +namespace Poco +{ +namespace Net +{ +class HTTPClientSession; +} + +} // namespace Poco + /// Represents whether the underlying file is locked /// and with what token. struct LockContext |