ucb/source/ucp/webdav-curl/webdavcontent.cxx | 34 ++++++++++++++++++++++++++- ucb/source/ucp/webdav-curl/webdavcontent.hxx | 3 ++ 2 files changed, 36 insertions(+), 1 deletion(-)
New commits: commit 9703240ea9c8932b32f16fd30c059d5e034fe9a0 Author: Giuseppe Castagno <[email protected]> AuthorDate: Sat Aug 27 12:29:21 2016 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Mon Nov 1 18:46:02 2021 +0100 ucb: webdav-curl: tdf#101094 (29) Fix for IIS 10.0 disabled OPTIONS method When OPTIONS methods (or verb) is disabled (or denied) on a IIS 10.0 web server, error 404 (e.g. 'Not Found') is emitted, so we need to deal with it. [ port of commit e0d0d87257d62ac61377a73909e17753f96e7aaa ] Change-Id: I67309f1bce20bba1399a9a3c22568291d095ac69 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123484 Tested-by: Michael Stahl <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx b/ucb/source/ucp/webdav-curl/webdavcontent.cxx index 237c51851af0..b96a58b3fb83 100644 --- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx +++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx @@ -3965,8 +3965,17 @@ void Content::getResourceOptions( break; case SC_NOT_FOUND: { + // Apparently on IIS 10.0, if you disabled OPTIONS method, this error is the one reported, + // instead of SC_NOT_IMPLEMENTED or SC_METHOD_NOT_ALLOWED. + // So check if this is an available resource, or a real 'Not Found' event. + sal_uInt32 nLifeTime = m_nOptsCacheLifeNotFound; + if( isResourceAvailable(xEnv, rResAccess ) ) + { + nLifeTime = m_nOptsCacheLifeNotImpl; + rDAVOptions.setResourceFound(); // means it exists, but it's not DAV + } aStaticDAVOptionsCache.addDAVOptions( rDAVOptions, - m_nOptsCacheLifeNotFound ); + nLifeTime ); SAL_WARN( "ucb.ucp.webdav", "OPTIONS - Resource not found for URL <" << m_xIdentifier->getContentIdentifier() << ">" ); } break; @@ -4015,4 +4024,27 @@ void Content::getResourceOptions( } +//static +bool Content::isResourceAvailable( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv, + const std::unique_ptr< DAVResourceAccess > & rResAccess ) +{ + try + { + // To check for the physical URL resource availability, using a simple HEAD command + // if HEAD is successfull, set element found. + std::vector< OUString > aHeaderNames; + DAVResource resource; + rResAccess->HEAD( aHeaderNames, resource, xEnv ); + return true; + } + catch ( ... ) + { + // some error... so set as not found + // retry errors are taken care of + // in rResAccess function method. + return false; + } +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.hxx b/ucb/source/ucp/webdav-curl/webdavcontent.hxx index f00b82634299..f854cc24047e 100644 --- a/ucb/source/ucp/webdav-curl/webdavcontent.hxx +++ b/ucb/source/ucp/webdav-curl/webdavcontent.hxx @@ -296,6 +296,9 @@ public: void getResourceOptions( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv, DAVOptions& rDAVOptions ); + static bool isResourceAvailable( const css::uno::Reference< css::ucb::XCommandEnvironment >& xEnv, + const std::unique_ptr< DAVResourceAccess > & rResAccess); + static void removeCachedPropertyNames( const OUString & rURL ); };
