[Libreoffice-commits] core.git: ucb/source
Giuseppe Castagno
giuseppe.castagno at acca-esse.eu
Thu Oct 13 12:29:47 UTC 2016
ucb/source/ucp/webdav-neon/DAVException.hxx | 4 ++++
ucb/source/ucp/webdav-neon/webdavcontent.cxx | 26 ++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
New commits:
commit 97cc70d7285526ae2ee3b3bac425eb031c4c0321
Author: Giuseppe Castagno <giuseppe.castagno at acca-esse.eu>
Date: Thu Oct 13 09:34:19 2016 +0200
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.
Change-Id: Iec4927d18ace5384fed16a7ec2a2620dc8305c5b
Reviewed-on: https://gerrit.libreoffice.org/29757
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Giuseppe Castagno <giuseppe.castagno at acca-esse.eu>
diff --git a/ucb/source/ucp/webdav-neon/DAVException.hxx b/ucb/source/ucp/webdav-neon/DAVException.hxx
index 424445c..a7e57ca 100644
--- a/ucb/source/ucp/webdav-neon/DAVException.hxx
+++ b/ucb/source/ucp/webdav-neon/DAVException.hxx
@@ -101,6 +101,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-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index a292128..cd32145c12 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
@@ -3943,6 +3943,26 @@ 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
+ NeonUri theUri( rURL );
+ OUString aHostName = theUri.GetHost();
+ sal_Int32 nPort = theUri.GetPort();
+ throw DAVException( DAVException::DAV_HTTP_TIMEOUT,
+ NeonUri::makeConnectionEndPointString( 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
{
@@ -4045,6 +4065,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
}
More information about the Libreoffice-commits
mailing list