From dde2af139b275329e6aeed28d53dbf3625629a70 Mon Sep 17 00:00:00 2001 From: jontje Date: Fri, 22 Feb 2019 15:56:10 +0100 Subject: [PATCH] Updated HTTP timeout implementation --- include/abb_librws/rws_interface.h | 10 ++++++++++ include/abb_librws/rws_poco_client.h | 26 +++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/include/abb_librws/rws_interface.h b/include/abb_librws/rws_interface.h index 4f6c787f..38654051 100644 --- a/include/abb_librws/rws_interface.h +++ b/include/abb_librws/rws_interface.h @@ -478,6 +478,16 @@ class RWSInterface */ std::string getLogText(const bool verbose = false); + /** + * \brief A method for setting the HTTP communication timeout. + * + * \param timeout for the HTTP communication timeout [microseconds]. + */ + void setHTTPTimeout(const Poco::Int64 timeout) + { + rws_client_.setHTTPTimeout(timeout); + } + protected: /** * \brief A method for comparing a single text content (from a XML document node) with a specific string value. diff --git a/include/abb_librws/rws_poco_client.h b/include/abb_librws/rws_poco_client.h index 009c2ece..7a8faad2 100644 --- a/include/abb_librws/rws_poco_client.h +++ b/include/abb_librws/rws_poco_client.h @@ -259,7 +259,7 @@ class POCOClient http_credentials_(username, password) { http_client_session_.setKeepAlive(true); - http_client_session_.setTimeout(Poco::Timespan(DEFAULT_TIMEOUT)); + http_client_session_.setTimeout(Poco::Timespan(DEFAULT_HTTP_TIMEOUT)); } /** @@ -306,14 +306,15 @@ class POCOClient POCOResult httpDelete(const std::string uri); /** - * \brief A method for resetting the timeout to the default value. - */ - void resetTimeout() { http_client_session_.setTimeout(Poco::Timespan(DEFAULT_TIMEOUT)); } - - /** - * \brief A method for setting the timeout to a long value. + * \brief A method for setting the HTTP communication timeout. + * + * \param timeout for the HTTP communication timeout [microseconds]. */ - void setLongTimeout() { http_client_session_.setTimeout(Poco::Timespan(LONG_TIMEOUT)); } + void setHTTPTimeout(const Poco::Int64 timeout) + { + http_client_session_.setTimeout(Poco::Timespan(timeout)); + http_client_session_.reset(); + } /** * \brief A method for checking if the WebSocket exist. @@ -400,14 +401,9 @@ class POCOClient void extractAndStoreCookie(const std::string cookie_string); /** - * \brief Static constant for the default timeout for HTTP requests, in microseconds. - */ - static const Poco::Int64 DEFAULT_TIMEOUT = 400000; - - /** - * \brief Static constant for a long timeout for HTTP requests, in microseconds. + * \brief Static constant for the default HTTP communication timeout [microseconds]. */ - static const Poco::Int64 LONG_TIMEOUT = 10000000; + static const Poco::Int64 DEFAULT_HTTP_TIMEOUT = 400000; /** * \brief Static constant for the socket's buffer size.