summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2016-10-13 09:34:19 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2021-11-01 18:52:18 +0100
commit2346a19dfeba7f0f2082888ab76c1c731e9e591c (patch)
tree9976dc093bca92f02ea77f68cfd95db9ff84cf82 /ucb
parent805a4e9d3e03e1339e9149fa745ac14fe334ccdf (diff)
ucb: webdav-curl: tdf#102499 (7): Caching connect timeout or cannot connect.
An unofficial HTTP response status code is defined and used internally in LibreOffice WebDAV ucp provider in order to catch either the DAVException::DAV_HTTP_TIMEOUT state or the DAVException::DAV_HTTP_CONNECT state. [ port of commit 97cc70d7285526ae2ee3b3bac425eb031c4c0321 ] Change-Id: Idd5d412dd10131199f34a047055d098a0f74cf7e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123499 Tested-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/webdav-curl/DAVException.hxx4
-rw-r--r--ucb/source/ucp/webdav-curl/webdavcontent.cxx25
2 files changed, 29 insertions, 0 deletions
diff --git a/ucb/source/ucp/webdav-curl/DAVException.hxx b/ucb/source/ucp/webdav-curl/DAVException.hxx
index 4da64420cc00..c2f9f53acdd9 100644
--- a/ucb/source/ucp/webdav-curl/DAVException.hxx
+++ b/ucb/source/ucp/webdav-curl/DAVException.hxx
@@ -91,6 +91,10 @@ const sal_uInt16 SC_HTTP_VERSION_NOT_SUPPORTED = 505;
// DAV extensions (<https://tools.ietf.org/html/rfc4918#section-11>)
const sal_uInt16 SC_INSUFFICIENT_STORAGE = 507;
+// unofficial status codes only used internally by LO
+// used to cache the connection time out event
+const sal_uInt16 USC_CONNECTION_TIMED_OUT = 908;
+
class DAVException : public std::exception
{
diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index 7866ce132632..01bc742f0e25 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -3813,6 +3813,25 @@ Content::ResourceType Content::getResourceType(
{
rResAccess->resetUri();
+ // first check if the cached error can be mapped to DAVException::DAV_HTTP_TIMEOUT or mapped to DAVException::DAV_HTTP_CONNECT
+ if ( aDAVOptions.getHttpResponseStatusCode() == USC_CONNECTION_TIMED_OUT )
+ {
+ // behave same as DAVException::DAV_HTTP_TIMEOUT or DAVException::DAV_HTTP_CONNECT was thrown
+ try
+ {
+ // extract host name and connection port
+ CurlUri theUri( rResAccess->getURL() );
+ OUString aHostName = theUri.GetHost();
+ sal_Int32 nPort = theUri.GetPort();
+ throw DAVException( DAVException::DAV_HTTP_TIMEOUT,
+ ConnectionEndPointString(aHostName, nPort) );
+ }
+ catch ( DAVException& exp )
+ {
+ cancelCommandExecution( exp, xEnv );
+ }
+ }
+
if ( aDAVOptions.getHttpResponseStatusCode() != SC_NOT_FOUND &&
aDAVOptions.getHttpResponseStatusCode() != SC_GONE ) // the cached OPTIONS can have SC_GONE
{
@@ -3941,6 +3960,12 @@ void Content::getResourceOptions(
// probably a new bit stating 'timed out' should be added to opts var?
// in any case abort the command
SAL_WARN( "ucb.ucp.webdav", "OPTIONS - DAVException: DAV_HTTP_TIMEOUT or DAV_HTTP_CONNECT for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
+ // cache the internal unofficial status code
+
+ aDAVOptions.setHttpResponseStatusCode( USC_CONNECTION_TIMED_OUT );
+ // used only internally, so the text doesn't really matter..
+ aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
+ m_nOptsCacheLifeNotFound );
cancelCommandExecution( e, xEnv );
// unreachable
}