Skip to content

Commit

Permalink
Updated HTTP timeout implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jontje committed Feb 22, 2019
1 parent 843507a commit dde2af1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
10 changes: 10 additions & 0 deletions include/abb_librws/rws_interface.h
Expand Up @@ -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.
Expand Down
26 changes: 11 additions & 15 deletions include/abb_librws/rws_poco_client.h
Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit dde2af1

Please sign in to comment.