ucb/source/ucp/webdav-curl/DAVException.hxx  |    1 +
 ucb/source/ucp/webdav-curl/webdavcontent.cxx |    9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

New commits:
commit b789d13c5dbe8992deb8952ddab36ce3f232457d
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Jun 20 14:21:20 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Jun 21 11:33:00 2024 +0200

    ucb: webdav-curl: don't mash together HTTP_CONNECT and HTTP_TIMEOUT
    
    First a DAVException with DAV_HTTP_CONNECT is thrown, then it's
    converted to USC_CONNECTION_TIMED_OUT, then that is converted to
    DAVException with DAV_HTTP_TIMEOUT, a bit misleading.
    
    Change-Id: Ie5089d67d363f57eaa9e1ed057b36adb41e846d2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169277
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Jenkins
    (cherry picked from commit 21279261fda69855924271230e3ac736615fc95c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169287

diff --git a/ucb/source/ucp/webdav-curl/DAVException.hxx 
b/ucb/source/ucp/webdav-curl/DAVException.hxx
index 759e43f25f8e..bd3053305901 100644
--- a/ucb/source/ucp/webdav-curl/DAVException.hxx
+++ b/ucb/source/ucp/webdav-curl/DAVException.hxx
@@ -93,6 +93,7 @@ const sal_uInt16 SC_HTTP_VERSION_NOT_SUPPORTED       = 505;
 const sal_uInt16 SC_INSUFFICIENT_STORAGE             = 507;
 
 // unofficial status codes only used internally by LO
+const sal_uInt16 USC_CONNECT_FAILED                  = 907;
 // used to cache the connection time out event
 const sal_uInt16 USC_CONNECTION_TIMED_OUT            = 908;
     // name resolution failed
diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index 1b004017b482..c33e4cb24bcc 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -3889,7 +3889,8 @@ 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
+            if (aDAVOptions.getHttpResponseStatusCode() == USC_CONNECT_FAILED
+                || aDAVOptions.getHttpResponseStatusCode() == 
USC_CONNECTION_TIMED_OUT
                 // can't get any reliable info without auth => cancel request
                 || aDAVOptions.getHttpResponseStatusCode() == USC_AUTH_FAILED
                 || aDAVOptions.getHttpResponseStatusCode() == 
USC_AUTHPROXY_FAILED)
@@ -3904,6 +3905,9 @@ Content::ResourceType Content::getResourceType(
                     DAVException::ExceptionCode e{};
                     switch (aDAVOptions.getHttpResponseStatusCode())
                     {
+                        case USC_CONNECT_FAILED:
+                            e = DAVException::DAV_HTTP_CONNECT;
+                            break;
                         case USC_CONNECTION_TIMED_OUT:
                             e = DAVException::DAV_HTTP_TIMEOUT;
                             break;
@@ -4057,7 +4061,7 @@ void Content::getResourceOptions(
                     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 );
+                    aDAVOptions.setHttpResponseStatusCode(e.getError() == 
DAVException::DAV_HTTP_CONNECT ? USC_CONNECT_FAILED : USC_CONNECTION_TIMED_OUT);
                     // used only internally, so the text doesn't really 
matter..
                     aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
                                                           
m_nOptsCacheLifeNotFound );
@@ -4215,6 +4219,7 @@ void Content::getResourceOptions(
         if ( networkAccessAllowed != nullptr &&
              ( ( CachedResponseStatusCode == SC_NOT_FOUND ) ||
                ( CachedResponseStatusCode == SC_GONE ) ||
+               ( CachedResponseStatusCode == USC_CONNECT_FAILED ) ||
                ( CachedResponseStatusCode == USC_CONNECTION_TIMED_OUT ) ||
                ( CachedResponseStatusCode == USC_LOOKUP_FAILED ) ||
                ( CachedResponseStatusCode == USC_AUTH_FAILED ) ||

Reply via email to