[Libreoffice-commits] core.git: ucb/source
Giuseppe Castagno
giuseppe.castagno at acca-esse.eu
Fri Jul 29 15:07:56 UTC 2016
ucb/source/ucp/webdav-neon/webdavcontent.cxx | 173 +++++++++++++++++----------
1 file changed, 110 insertions(+), 63 deletions(-)
New commits:
commit 37ada6f457e19b6ee2d2adb0b0ab3acb20705b51
Author: Giuseppe Castagno <giuseppe.castagno at acca-esse.eu>
Date: Sun Jan 10 17:43:12 2016 +0100
tdf#101094 (12) OPTIONS: Add options cache ctrl in getResourceOptions
Change-Id: If4f53e8efc51e5ec33747dfcbe8f4294bbd6160b
Reviewed-on: https://gerrit.libreoffice.org/27685
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/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index 8c84f5d..78a09b9 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
@@ -3700,78 +3700,125 @@ void Content::getResourceOptions(
const std::unique_ptr< DAVResourceAccess > & rResAccess )
throw ( css::uno::Exception, std::exception )
{
- try
- {
- rResAccess->OPTIONS( rDAVOptions, xEnv );
- // IMPORTANT:the correctly implemented server will answer without errors, even if the resource is not present
- }
- catch ( DAVException const & e )
+ OUString aRedirURL;
+ OUString aTargetURL = rResAccess->getURL();
+ // first check if in cache, if not, then send method to server
+ if ( !aStaticDAVOptionsCache.getDAVOptions( aTargetURL, rDAVOptions ) )
{
- rResAccess->resetUri();
-
- switch( e.getError() )
+ try
{
- case DAVException::DAV_HTTP_TIMEOUT:
- case DAVException::DAV_HTTP_CONNECT:
- {
- // something bad happened to the connection
- // not same as not found, this instead happens when the server does'n exist or does'n aswer at all
- // probably a new bit stating 'timed out' should be added to opts var?
- // in any case abort the command
- cancelCommandExecution( e, xEnv );
- // unreachable
- }
- break;
- case DAVException::DAV_HTTP_AUTH:
- {
- SAL_WARN( "ucb.ucp.webdav", "OPTIONS - DAVException Authentication error for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
- // - the remote site is a WebDAV with special configuration: read/only for read operations
- // and read/write for write operations, the user is not allowed to lock/write and
- // she cancelled the credentials request.
- // this is not actually an error, it means only that for current user this is a standard web,
- // though possibly DAV enabled
+ rResAccess->OPTIONS( rDAVOptions, xEnv );
+ // IMPORTANT:the correctly implemented server will answer without errors, even if the resource is not present
+ sal_uInt32 nLifeTime = ( rDAVOptions.isClass1() ||
+ rDAVOptions.isClass2() ||
+ rDAVOptions.isClass3() ) ?
+ m_nOptsCacheLifeDAV : // a WebDAV site
+ m_nOptsCacheLifeImplWeb; // a site implementing OPTIONS but
+ // it's not DAV
+ // check if redirected
+ aRedirURL = rResAccess->getURL();
+ if( aRedirURL == aTargetURL)
+ { // no redirection
+ aRedirURL.clear();
}
- break;
- case DAVException::DAV_HTTP_ERROR:
+ // cache this URL's option
+ rDAVOptions.setURL( aTargetURL );
+ rDAVOptions.setRedirectedURL( aRedirURL );
+ aStaticDAVOptionsCache.addDAVOptions( rDAVOptions,
+ nLifeTime );
+ }
+ catch ( DAVException const & e )
+ {
+ // first, remove from cache, will be added if needed, depending on the error received
+ aStaticDAVOptionsCache.removeDAVOptions( aTargetURL );
+ rResAccess->resetUri();
+
+ rDAVOptions.setURL( aTargetURL );
+ rDAVOptions.setRedirectedURL( aRedirURL );
+ switch( e.getError() )
{
- switch( e.getStatus() )
+ case DAVException::DAV_HTTP_TIMEOUT:
+ case DAVException::DAV_HTTP_CONNECT:
{
- case SC_FORBIDDEN:
- {
- SAL_WARN( "ucb.ucp.webdav","OPTIONS - Forbidden for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
- rDAVOptions.setResourceFound(); // means it exists, but it's not DAV
- }
- break;
- case SC_BAD_REQUEST:
- {
- SAL_WARN( "ucb.ucp.webdav","OPTIONS - Bad request for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
- rDAVOptions.setResourceFound(); // means it exists, but it's not DAV
- }
- break;
- case SC_NOT_IMPLEMENTED:
- case SC_METHOD_NOT_ALLOWED:
- {
- // OPTIONS method must be implemented in DAV
- // resource is NON_DAV, or not advertising it
- SAL_WARN( "ucb.ucp.webdav","OPTIONS - Method not implemented or not allowed for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
- rDAVOptions.setResourceFound(); // means it exists, but it's not DAV
- }
- break;
- case SC_NOT_FOUND:
+ // something bad happened to the connection
+ // not same as not found, this instead happens when the server does'n exist or does'n aswer at all
+ // probably a new bit stating 'timed out' should be added to opts var?
+ // in any case abort the command
+ cancelCommandExecution( e, xEnv );
+ // unreachable
+ }
+ break;
+ case DAVException::DAV_HTTP_AUTH:
+ {
+ SAL_WARN( "ucb.ucp.webdav", "OPTIONS - DAVException Authentication error for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
+ // - the remote site is a WebDAV with special configuration: read/only for read operations
+ // and read/write for write operations, the user is not allowed to lock/write and
+ // she cancelled the credentials request.
+ // this is not actually an error, it means only that for current user this is a standard web,
+ // though possibly DAV enabled
+ }
+ break;
+ case DAVException::DAV_HTTP_ERROR:
+ {
+ switch( e.getStatus() )
{
- SAL_WARN( "ucb.ucp.webdav", "OPTIONS - Resource not found for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
- }
- break;
- default:
+ case SC_FORBIDDEN:
+ {
+ SAL_WARN( "ucb.ucp.webdav","OPTIONS - Forbidden for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
+ rDAVOptions.setResourceFound(); // it may exists, will be checked by HEAD or GET method, surely it's not DAV
+ // cache it, so OPTIONS won't be called again, this URL does not support it
+ aStaticDAVOptionsCache.addDAVOptions( rDAVOptions,
+ m_nOptsCacheLifeNotImpl );
+ }
break;
+ case SC_BAD_REQUEST:
+ {
+ SAL_WARN( "ucb.ucp.webdav","OPTIONS - Bad request for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
+ rDAVOptions.setResourceFound(); // it may exists, will be checked by HEAD or GET method, surely it's not DAV
+ // cache it, so OPTIONS won't be called again, this URL does not support it
+ aStaticDAVOptionsCache.addDAVOptions( rDAVOptions,
+ m_nOptsCacheLifeNotImpl );
+ }
+ break;
+ case SC_NOT_IMPLEMENTED:
+ case SC_METHOD_NOT_ALLOWED:
+ {
+ // OPTIONS method must be implemented in DAV
+ // resource is NON_DAV, or not advertising it
+ SAL_WARN( "ucb.ucp.webdav","OPTIONS - Method not implemented or not allowed for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
+ rDAVOptions.setResourceFound(); // means it exists, but it's not DAV
+ // cache it, so OPTIONS won't be called again, this URL does not support it
+ aStaticDAVOptionsCache.addDAVOptions( rDAVOptions,
+ m_nOptsCacheLifeNotImpl );
+ }
+ break;
+ case SC_NOT_FOUND:
+ {
+ aStaticDAVOptionsCache.addDAVOptions( rDAVOptions,
+ m_nOptsCacheLifeNotFound );
+ SAL_WARN( "ucb.ucp.webdav", "OPTIONS - Resource not found for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
+ }
+ break;
+ default:
+ SAL_WARN( "ucb.ucp.webdav", "OPTIONS - DAVException, HTTP error: " << e.getError() << " for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
+ rDAVOptions.setResourceFound(); // it may exists, will be checked by HEAD or GET method, surely it's not DAV
+ // cache it, so OPTIONS won't be called again, this URL does not support it
+ aStaticDAVOptionsCache.addDAVOptions( rDAVOptions,
+ m_nOptsCacheLifeNotImpl );
+ break;
+ }
}
- }
- break;
- default: // leave the resource type as UNKNOWN, for now
- // it means this will be managed as a standard http site
- SAL_WARN( "ucb.ucp.webdav","OPTIONS - DAVException for URL <" << m_xIdentifier->getContentIdentifier() << ">, DAV error: "
- << e.getError() << ", HTTP error: "<<e.getStatus() );
break;
+ default: // leave the resource type as UNKNOWN, for now
+ // it means this will be managed as a standard http site
+ SAL_WARN( "ucb.ucp.webdav","OPTIONS - DAVException for URL <" << m_xIdentifier->getContentIdentifier() << ">, DAV error: "
+ << e.getError() << ", HTTP error: "<<e.getStatus() );
+ rDAVOptions.setResourceFound(); // it may exists, will be checked by HEAD or GET method, surely it's not DAV
+ // cache it, so OPTIONS won't be called again, this URL does not support it
+ aStaticDAVOptionsCache.addDAVOptions( rDAVOptions,
+ m_nOptsCacheLifeNotImpl );
+ break;
+ }
}
}
}
More information about the Libreoffice-commits
mailing list