Kaydet (Commit) 16df731a authored tarafından Giuseppe Castagno's avatar Giuseppe Castagno

tdf#102499 (5): Deal with HTTP unofficial response status codes

A reference can be found here:
<https://en.wikipedia.org/wiki/List_of_HTTP_status_codes>
(retrieved 2016-09-13).

Changes done:
Add set of 'HEAD method not available' before using fall back GET method.
Add new method in OPTIONS cache.
Add response status code if fall-back GET didn't succeeded.
Add copy-assignement operator to DAVOptions.
Fix behaviour of GET fall back when HEAD missing.

Change-Id: I6aad0e22bb444abf37b90186588f64f79b03cc3d
Reviewed-on: https://gerrit.libreoffice.org/29680Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>
üst 08655031
...@@ -34,7 +34,6 @@ DAVOptions::DAVOptions() : ...@@ -34,7 +34,6 @@ DAVOptions::DAVOptions() :
{ {
} }
DAVOptions::DAVOptions( const DAVOptions & rOther ) : DAVOptions::DAVOptions( const DAVOptions & rOther ) :
m_isClass1( rOther.m_isClass1 ), m_isClass1( rOther.m_isClass1 ),
m_isClass2( rOther.m_isClass2 ), m_isClass2( rOther.m_isClass2 ),
...@@ -50,11 +49,25 @@ DAVOptions::DAVOptions( const DAVOptions & rOther ) : ...@@ -50,11 +49,25 @@ DAVOptions::DAVOptions( const DAVOptions & rOther ) :
{ {
} }
DAVOptions::~DAVOptions() DAVOptions::~DAVOptions()
{ {
} }
DAVOptions & DAVOptions::operator=( const DAVOptions& rOpts )
{
m_isClass1 = rOpts.m_isClass1;
m_isClass2 = rOpts.m_isClass2;
m_isClass3 = rOpts.m_isClass3;
m_isLocked = rOpts.m_isLocked;
m_isHeadAllowed = rOpts.m_isHeadAllowed;
m_aAllowedMethods = rOpts.m_aAllowedMethods;
m_nStaleTime = rOpts.m_nStaleTime;
m_sURL = rOpts.m_sURL;
m_sRedirectedURL = rOpts.m_sRedirectedURL;
m_nHttpResponseStatusCode = rOpts.m_nHttpResponseStatusCode;
m_sHttpResponseStatusText = rOpts.m_sHttpResponseStatusText;
return *this;
}
bool DAVOptions::operator==( const DAVOptions& rOpts ) const bool DAVOptions::operator==( const DAVOptions& rOpts ) const
{ {
...@@ -79,12 +92,10 @@ DAVOptionsCache::DAVOptionsCache() ...@@ -79,12 +92,10 @@ DAVOptionsCache::DAVOptionsCache()
{ {
} }
DAVOptionsCache::~DAVOptionsCache() DAVOptionsCache::~DAVOptionsCache()
{ {
} }
bool DAVOptionsCache::getDAVOptions( const OUString & rURL, DAVOptions & rDAVOptions ) bool DAVOptionsCache::getDAVOptions( const OUString & rURL, DAVOptions & rDAVOptions )
{ {
osl::MutexGuard aGuard( m_aMutex ); osl::MutexGuard aGuard( m_aMutex );
...@@ -113,7 +124,6 @@ bool DAVOptionsCache::getDAVOptions( const OUString & rURL, DAVOptions & rDAVOpt ...@@ -113,7 +124,6 @@ bool DAVOptionsCache::getDAVOptions( const OUString & rURL, DAVOptions & rDAVOpt
} }
} }
void DAVOptionsCache::removeDAVOptions( const OUString & rURL ) void DAVOptionsCache::removeDAVOptions( const OUString & rURL )
{ {
osl::MutexGuard aGuard( m_aMutex ); osl::MutexGuard aGuard( m_aMutex );
...@@ -128,7 +138,6 @@ void DAVOptionsCache::removeDAVOptions( const OUString & rURL ) ...@@ -128,7 +138,6 @@ void DAVOptionsCache::removeDAVOptions( const OUString & rURL )
} }
} }
void DAVOptionsCache::addDAVOptions( DAVOptions & rDAVOptions, const sal_uInt32 nLifeTime ) void DAVOptionsCache::addDAVOptions( DAVOptions & rDAVOptions, const sal_uInt32 nLifeTime )
{ {
osl::MutexGuard aGuard( m_aMutex ); osl::MutexGuard aGuard( m_aMutex );
...@@ -149,6 +158,39 @@ void DAVOptionsCache::addDAVOptions( DAVOptions & rDAVOptions, const sal_uInt32 ...@@ -149,6 +158,39 @@ void DAVOptionsCache::addDAVOptions( DAVOptions & rDAVOptions, const sal_uInt32
m_aTheCache[ aEncodedUrl ] = rDAVOptions; m_aTheCache[ aEncodedUrl ] = rDAVOptions;
} }
void DAVOptionsCache::updateCachedOption( DAVOptions & rDAVOptions, const sal_uInt32 nLifeTime )
{
osl::MutexGuard aGuard( m_aMutex );
OUString aURL( rDAVOptions.getURL() );
OUString aEncodedUrl( ucb_impl::urihelper::encodeURI( NeonUri::unescape( aURL ) ) );
normalizeURLLastChar( aEncodedUrl );
rDAVOptions.setURL( aEncodedUrl );
// unchanged, it may be used to access a server
OUString aRedirURL( rDAVOptions.getRedirectedURL() );
rDAVOptions.setRedirectedURL( aRedirURL );
// check if already cached
DAVOptionsMap::iterator it;
it = m_aTheCache.find( aEncodedUrl );
if ( it != m_aTheCache.end() )
{
DAVOptions &opts = (*it).second;
// exists, set new staletime, only if remaining time is higher
TimeValue t1;
osl_getSystemTime( &t1 );
if ( ( opts.getStaleTime() - t1.Seconds ) > nLifeTime )
{
opts.setStaleTime( t1.Seconds + nLifeTime );
}
// update relevant fields
opts.setHttpResponseStatusCode( rDAVOptions.getHttpResponseStatusCode() );
opts.setHttpResponseStatusText( rDAVOptions.getHttpResponseStatusText() );
}
}
sal_uInt16 DAVOptionsCache::getHttpResponseStatusCode( const OUString & rURL, OUString & rHttpResponseStatusText ) sal_uInt16 DAVOptionsCache::getHttpResponseStatusCode( const OUString & rURL, OUString & rHttpResponseStatusText )
{ {
osl::MutexGuard aGuard( m_aMutex ); osl::MutexGuard aGuard( m_aMutex );
...@@ -174,6 +216,29 @@ sal_uInt16 DAVOptionsCache::getHttpResponseStatusCode( const OUString & rURL, OU ...@@ -174,6 +216,29 @@ sal_uInt16 DAVOptionsCache::getHttpResponseStatusCode( const OUString & rURL, OU
return 0; return 0;
} }
void DAVOptionsCache::setHeadAllowed( const OUString & rURL, const bool HeadAllowed )
{
osl::MutexGuard aGuard( m_aMutex );
OUString aEncodedUrl( ucb_impl::urihelper::encodeURI( NeonUri::unescape( rURL ) ) );
normalizeURLLastChar( aEncodedUrl );
DAVOptionsMap::iterator it;
it = m_aTheCache.find( aEncodedUrl );
if ( it != m_aTheCache.end() )
{
// first check for stale
TimeValue t1;
osl_getSystemTime( &t1 );
if( (*it).second.getStaleTime() < t1.Seconds )
{
m_aTheCache.erase( it );
return;
}
// check if the resource was present on server
(*it).second.setHeadAllowed( HeadAllowed );
}
}
bool DAVOptionsCache::isHeadAllowed( const OUString & rURL ) bool DAVOptionsCache::isHeadAllowed( const OUString & rURL )
{ {
osl::MutexGuard aGuard( m_aMutex ); osl::MutexGuard aGuard( m_aMutex );
......
...@@ -152,6 +152,7 @@ namespace webdav_ucp ...@@ -152,6 +152,7 @@ namespace webdav_ucp
m_sHttpResponseStatusText.clear(); m_sHttpResponseStatusText.clear();
}; };
DAVOptions & operator=( const DAVOptions& rOpts );
bool operator==( const DAVOptions& rOpts ) const; bool operator==( const DAVOptions& rOpts ) const;
}; };
...@@ -174,6 +175,8 @@ namespace webdav_ucp ...@@ -174,6 +175,8 @@ namespace webdav_ucp
void removeDAVOptions( const OUString & rURL ); void removeDAVOptions( const OUString & rURL );
void addDAVOptions( DAVOptions & rDAVOptions, const sal_uInt32 nLifeTime ); void addDAVOptions( DAVOptions & rDAVOptions, const sal_uInt32 nLifeTime );
void updateCachedOption( DAVOptions & rDAVOptions, const sal_uInt32 nLifeTime );
/** return the cached value of HTTP response status code /** return the cached value of HTTP response status code
If the cached value is found stale, it is removed. If the cached value is found stale, it is removed.
...@@ -190,6 +193,8 @@ namespace webdav_ucp ...@@ -190,6 +193,8 @@ namespace webdav_ucp
bool isHeadAllowed( const OUString & rURL ); bool isHeadAllowed( const OUString & rURL );
void setHeadAllowed( const OUString & rURL, bool HeadAllowed = true );
private: private:
/// remove the last '/' in aUrl, if it exists /// remove the last '/' in aUrl, if it exists
......
...@@ -1841,33 +1841,106 @@ void NeonSession::HandleError( int nError, ...@@ -1841,33 +1841,106 @@ void NeonSession::HandleError( int nError,
sal_uInt16 code = makeStatusCode( aText ); sal_uInt16 code = makeStatusCode( aText );
SAL_WARN( "ucb.ucp.webdav", "Neon returned NE_ERROR, http response status code was: " << code << " '" << aText << "'" ); SAL_WARN( "ucb.ucp.webdav", "Neon returned NE_ERROR, http response status code was: " << code << " '" << aText << "'" );
if ( code == SC_LOCKED ) if ( SC_BAD_REQUEST <= code && code < SC_INTERNAL_SERVER_ERROR )
{ {
if ( m_aNeonLockStore.findByUri( // error codes in the range 4xx
makeAbsoluteURL( inPath ) ) == nullptr ) switch ( code )
{ {
// locked by 3rd party case SC_LOCKED:
throw DAVException( DAVException::DAV_LOCKED ); {
} if ( m_aNeonLockStore.findByUri(
else makeAbsoluteURL( inPath ) ) == nullptr )
{ {
// locked by ourself // locked by 3rd party
throw DAVException( DAVException::DAV_LOCKED_SELF ); throw DAVException( DAVException::DAV_LOCKED );
}
else
{
// locked by ourself
throw DAVException( DAVException::DAV_LOCKED_SELF );
}
}
break;
case SC_PRECONDITION_FAILED:
case SC_BAD_REQUEST:
{
// Special handling for 400 and 412 status codes, which may indicate
// that a lock previously obtained by us has been released meanwhile
// by the server. Unfortunately, RFC is not clear at this point,
// thus server implementations behave different...
if ( removeExpiredLocktoken( makeAbsoluteURL( inPath ), rEnv ) )
throw DAVException( DAVException::DAV_LOCK_EXPIRED );
}
break;
case SC_REQUEST_TIMEOUT:
{
throw DAVException( DAVException::DAV_HTTP_TIMEOUT,
NeonUri::makeConnectionEndPointString(
m_aHostName, m_nPort ) );
}
break;
case SC_UNAUTHORIZED: // User authentication failed on server
{
throw DAVException( DAVException::DAV_HTTP_AUTH,
NeonUri::makeConnectionEndPointString(
m_aHostName, m_nPort ) );
}
break;
case SC_GONE:
case SC_LENGTH_REQUIRED:
case SC_REQUEST_ENTITY_TOO_LARGE:
case SC_REQUEST_URI_TOO_LONG:
case SC_UNSUPPORTED_MEDIA_TYPE:
case SC_REQUESTED_RANGE_NOT_SATISFIABLE:
case SC_EXPECTATION_FAILED:
case SC_UNPROCESSABLE_ENTITY:
case SC_FAILED_DEPENDENCY:
case SC_CONFLICT:
case SC_NOT_ACCEPTABLE:
case SC_PAYMENT_REQUIRED:
case SC_PROXY_AUTHENTICATION_REQUIRED:
default:
// set 400 error, if not one of others
code = SC_BAD_REQUEST;
SAL_FALLTHROUGH;
case SC_FORBIDDEN:
case SC_NOT_FOUND:
case SC_METHOD_NOT_ALLOWED:
throw DAVException( DAVException::DAV_HTTP_ERROR, aText, code );
break;
} }
} }
else if ( SC_INTERNAL_SERVER_ERROR <= code )
// Special handling for 400 and 412 status codes, which may indicate
// that a lock previously obtained by us has been released meanwhile
// by the server. Unfortunately, RFC is not clear at this point,
// thus server implementations behave different...
else if ( code == SC_BAD_REQUEST || code == SC_PRECONDITION_FAILED )
{ {
if ( removeExpiredLocktoken( makeAbsoluteURL( inPath ), rEnv ) ) // deal with HTTP response status codes higher then 500
throw DAVException( DAVException::DAV_LOCK_EXPIRED ); // error codes in the range 5xx, server errors
// but there exists unofficial code in the range 1000 and up
// for example see:
// <https://support.cloudflare.com/hc/en-us/sections/200820298-Error-Pages> (retrieved 2016-10-05)
switch ( code )
{
// the error codes case before the default case are not actively
// managed by LO
case SC_BAD_GATEWAY:
case SC_SERVICE_UNAVAILABLE:
case SC_GATEWAY_TIMEOUT:
case SC_HTTP_VERSION_NOT_SUPPORTED:
case SC_INSUFFICIENT_STORAGE:
default:
// set 500 error, if not one of others
// expand the error code
code = SC_INTERNAL_SERVER_ERROR;
SAL_FALLTHROUGH;
case SC_INTERNAL_SERVER_ERROR:
case SC_NOT_IMPLEMENTED:
throw DAVException( DAVException::DAV_HTTP_ERROR, aText, code );
break;
}
} }
else
throw DAVException( DAVException::DAV_HTTP_ERROR, aText, code ); throw DAVException( DAVException::DAV_HTTP_ERROR, aText, code );
} }
break;
case NE_LOOKUP: // Name lookup failed. case NE_LOOKUP: // Name lookup failed.
SAL_WARN( "ucb.ucp.webdav", "Name lookup failed" ); SAL_WARN( "ucb.ucp.webdav", "Name lookup failed" );
throw DAVException( DAVException::DAV_HTTP_LOOKUP, throw DAVException( DAVException::DAV_HTTP_LOOKUP,
......
...@@ -1590,8 +1590,13 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( ...@@ -1590,8 +1590,13 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
// PROPPATCH can change them // PROPPATCH can change them
removeCachedPropertyNames( aTargetURL ); removeCachedPropertyNames( aTargetURL );
// test if HEAD allowed, if not, throw, will be catched immediately // test if HEAD allowed, if not, throw, will be catched immediately
if ( !aDAVOptions.isHeadAllowed() ) // SC_GONE used internally by us, see comment below
// in the catch scope
if ( aDAVOptions.getHttpResponseStatusCode() != SC_GONE &&
!aDAVOptions.isHeadAllowed() )
{
throw DAVException( DAVException::DAV_HTTP_ERROR, "405 Not Implemented", 405 ); throw DAVException( DAVException::DAV_HTTP_ERROR, "405 Not Implemented", 405 );
}
// if HEAD is enabled on this site // if HEAD is enabled on this site
// check if there is a relevant HTTP response status code cached // check if there is a relevant HTTP response status code cached
if ( aDAVOptions.getHttpResponseStatusCode() != SC_NONE ) if ( aDAVOptions.getHttpResponseStatusCode() != SC_NONE )
...@@ -1645,6 +1650,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( ...@@ -1645,6 +1650,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
aLastException.getStatus() == SC_NOT_FOUND ) aLastException.getStatus() == SC_NOT_FOUND )
{ {
SAL_WARN( "ucb.ucp.webdav", "HEAD probably not implemented: fall back to a partial GET" ); SAL_WARN( "ucb.ucp.webdav", "HEAD probably not implemented: fall back to a partial GET" );
aStaticDAVOptionsCache.setHeadAllowed( aTargetURL, false );
lcl_sendPartialGETRequest( bError, lcl_sendPartialGETRequest( bError,
aLastException, aLastException,
aMissingProps, aMissingProps,
...@@ -1658,10 +1664,27 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( ...@@ -1658,10 +1664,27 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
if ( bError ) if ( bError )
{ {
DAVOptions aDAVOptionsException;
aDAVOptionsException.setURL( aTargetURL );
// check if the error was SC_NOT_FOUND, meaning that the
// GET fall back didn't succeeded and the element is really missing
// we will consider the resource SC_GONE (410) for some time
// we use SC_GONE because has the same meaning of SC_NOT_FOUND (404)
// see:
// <https://tools.ietf.org/html/rfc7231#section-6.5.9> (retrieved 2016-10-09)
// apparently it's not used to mark the missing HEAD method (so far...)
sal_uInt16 ResponseStatusCode =
( aLastException.getStatus() == SC_NOT_FOUND ) ?
SC_GONE :
aLastException.getStatus();
aDAVOptionsException.setHttpResponseStatusCode( ResponseStatusCode );
aDAVOptionsException.setHttpResponseStatusText( aLastException.getData() );
aStaticDAVOptionsCache.updateCachedOption( aDAVOptionsException,
m_nOptsCacheLifeNotFound );
if ( !shouldAccessNetworkAfterException( aLastException ) ) if ( !shouldAccessNetworkAfterException( aLastException ) )
{ {
// remove the cached OPTIONS and errors
aStaticDAVOptionsCache.removeDAVOptions( aTargetURL );
cancelCommandExecution( aLastException, xEnv ); cancelCommandExecution( aLastException, xEnv );
// unreachable // unreachable
} }
...@@ -2348,6 +2371,7 @@ uno::Any Content::open( ...@@ -2348,6 +2371,7 @@ uno::Any Content::open(
} }
catch ( DAVException const & e ) catch ( DAVException const & e )
{ {
//TODO cache the http error if not yet cached
cancelCommandExecution( e, xEnv ); cancelCommandExecution( e, xEnv );
// Unreachable // Unreachable
} }
...@@ -3729,6 +3753,7 @@ uno::Any Content::MapDAVException( const DAVException & e, bool bWrite ) ...@@ -3729,6 +3753,7 @@ uno::Any Content::MapDAVException( const DAVException & e, bool bWrite )
bool Content::shouldAccessNetworkAfterException( const DAVException & e ) bool Content::shouldAccessNetworkAfterException( const DAVException & e )
{ {
if ( ( e.getStatus() == SC_NOT_FOUND ) || if ( ( e.getStatus() == SC_NOT_FOUND ) ||
( e.getStatus() == SC_GONE ) ||
( e.getError() == DAVException::DAV_HTTP_TIMEOUT ) || ( e.getError() == DAVException::DAV_HTTP_TIMEOUT ) ||
( e.getError() == DAVException::DAV_HTTP_LOOKUP ) || ( e.getError() == DAVException::DAV_HTTP_LOOKUP ) ||
( e.getError() == DAVException::DAV_HTTP_CONNECT ) || ( e.getError() == DAVException::DAV_HTTP_CONNECT ) ||
...@@ -3918,7 +3943,8 @@ Content::ResourceType Content::getResourceType( ...@@ -3918,7 +3943,8 @@ Content::ResourceType Content::getResourceType(
{ {
rResAccess->resetUri(); rResAccess->resetUri();
if ( aDAVOptions.getHttpResponseStatusCode() != SC_NOT_FOUND ) if ( aDAVOptions.getHttpResponseStatusCode() != SC_NOT_FOUND &&
aDAVOptions.getHttpResponseStatusCode() != SC_GONE ) // the cached OPTIONS can have SC_GONE
{ {
eResourceType = NON_DAV; eResourceType = NON_DAV;
} }
...@@ -3926,8 +3952,7 @@ Content::ResourceType Content::getResourceType( ...@@ -3926,8 +3952,7 @@ Content::ResourceType Content::getResourceType(
{ {
//resource doesn't exist //resource doesn't exist
if ( networkAccessAllowed != nullptr ) if ( networkAccessAllowed != nullptr )
*networkAccessAllowed = false; *networkAccessAllowed = false; }
}
} }
} }
...@@ -3971,22 +3996,23 @@ void Content::getResourceOptions( ...@@ -3971,22 +3996,23 @@ void Content::getResourceOptions(
{ {
OUString aRedirURL; OUString aRedirURL;
OUString aTargetURL = rResAccess->getURL(); OUString aTargetURL = rResAccess->getURL();
DAVOptions aDAVOptions;
// first check if in cache, if not, then send method to server // first check if in cache, if not, then send method to server
if ( !aStaticDAVOptionsCache.getDAVOptions( aTargetURL, rDAVOptions ) ) if ( !aStaticDAVOptionsCache.getDAVOptions( aTargetURL, aDAVOptions ) )
{ {
try try
{ {
rResAccess->OPTIONS( rDAVOptions, xEnv ); rResAccess->OPTIONS( aDAVOptions, xEnv );
// IMPORTANT:the correctly implemented server will answer without errors, even if the resource is not present // IMPORTANT:the correctly implemented server will answer without errors, even if the resource is not present
sal_uInt32 nLifeTime = ( rDAVOptions.isClass1() || sal_uInt32 nLifeTime = ( aDAVOptions.isClass1() ||
rDAVOptions.isClass2() || aDAVOptions.isClass2() ||
rDAVOptions.isClass3() ) ? aDAVOptions.isClass3() ) ?
m_nOptsCacheLifeDAV : // a WebDAV site m_nOptsCacheLifeDAV : // a WebDAV site
m_nOptsCacheLifeImplWeb; // a site implementing OPTIONS but m_nOptsCacheLifeImplWeb; // a site implementing OPTIONS but
// it's not DAV // it's not DAV
// if resource is locked, will use a // if resource is locked, will use a
// different lifetime // different lifetime
if( rDAVOptions.isLocked() ) if( aDAVOptions.isLocked() )
nLifeTime = m_nOptsCacheLifeDAVLocked; nLifeTime = m_nOptsCacheLifeDAVLocked;
// check if redirected // check if redirected
...@@ -3996,9 +4022,9 @@ void Content::getResourceOptions( ...@@ -3996,9 +4022,9 @@ void Content::getResourceOptions(
aRedirURL.clear(); aRedirURL.clear();
} }
// cache this URL's option // cache this URL's option
rDAVOptions.setURL( aTargetURL ); aDAVOptions.setURL( aTargetURL );
rDAVOptions.setRedirectedURL( aRedirURL ); aDAVOptions.setRedirectedURL( aRedirURL );
aStaticDAVOptionsCache.addDAVOptions( rDAVOptions, aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
nLifeTime ); nLifeTime );
} }
catch ( DAVException const & e ) catch ( DAVException const & e )
...@@ -4007,8 +4033,8 @@ void Content::getResourceOptions( ...@@ -4007,8 +4033,8 @@ void Content::getResourceOptions(
aStaticDAVOptionsCache.removeDAVOptions( aTargetURL ); aStaticDAVOptionsCache.removeDAVOptions( aTargetURL );
rResAccess->resetUri(); rResAccess->resetUri();
rDAVOptions.setURL( aTargetURL ); aDAVOptions.setURL( aTargetURL );
rDAVOptions.setRedirectedURL( aRedirURL ); aDAVOptions.setRedirectedURL( aRedirURL );
switch( e.getError() ) switch( e.getError() )
{ {
case DAVException::DAV_HTTP_TIMEOUT: case DAVException::DAV_HTTP_TIMEOUT:
...@@ -4041,16 +4067,20 @@ void Content::getResourceOptions( ...@@ -4041,16 +4067,20 @@ void Content::getResourceOptions(
{ {
SAL_WARN( "ucb.ucp.webdav","OPTIONS - SC_FORBIDDEN for URL <" << m_xIdentifier->getContentIdentifier() << ">" ); SAL_WARN( "ucb.ucp.webdav","OPTIONS - SC_FORBIDDEN for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
// cache it, so OPTIONS won't be called again, this URL does not support it // cache it, so OPTIONS won't be called again, this URL does not support it
aStaticDAVOptionsCache.addDAVOptions( rDAVOptions, aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
m_nOptsCacheLifeNotImpl ); m_nOptsCacheLifeNotImpl );
} }
break; break;
case SC_BAD_REQUEST: case SC_BAD_REQUEST:
case SC_INTERNAL_SERVER_ERROR:
{ {
SAL_WARN( "ucb.ucp.webdav","OPTIONS - SC_BAD_REQUEST for URL <" << m_xIdentifier->getContentIdentifier() << ">" ); SAL_WARN( "ucb.ucp.webdav","OPTIONS - SC_BAD_REQUEST or SC_INTERNAL_SERVER_ERROR for URL <" << m_xIdentifier->getContentIdentifier() << ">, HTTP error: "<< e.getStatus()
// cache it, so OPTIONS won't be called again, this URL does not support it << ", '" << e.getData() << "'" );
aStaticDAVOptionsCache.addDAVOptions( rDAVOptions, // cache it, so OPTIONS won't be called again, this URL detect some problem while answering the method
m_nOptsCacheLifeNotImpl ); aDAVOptions.setHttpResponseStatusCode( e.getStatus() );
aDAVOptions.setHttpResponseStatusText( e.getData() );
aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
m_nOptsCacheLifeNotFound );
} }
break; break;
case SC_NOT_IMPLEMENTED: case SC_NOT_IMPLEMENTED:
...@@ -4058,9 +4088,10 @@ void Content::getResourceOptions( ...@@ -4058,9 +4088,10 @@ void Content::getResourceOptions(
{ {
// OPTIONS method must be implemented in DAV // OPTIONS method must be implemented in DAV
// resource is NON_DAV, or not advertising it // resource is NON_DAV, or not advertising it
SAL_WARN( "ucb.ucp.webdav","OPTIONS - SC_NOT_IMPLEMENTED or SC_METHOD_NOT_ALLOWED for URL <" << m_xIdentifier->getContentIdentifier() << ">" ); SAL_WARN( "ucb.ucp.webdav","OPTIONS - SC_NOT_IMPLEMENTED or SC_METHOD_NOT_ALLOWED for URL <" << m_xIdentifier->getContentIdentifier() << ">, HTTP error: "<< e.getStatus()
<< ", '" << e.getData() << "'" );
// cache it, so OPTIONS won't be called again, this URL does not support it // cache it, so OPTIONS won't be called again, this URL does not support it
aStaticDAVOptionsCache.addDAVOptions( rDAVOptions, aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
m_nOptsCacheLifeNotImpl ); m_nOptsCacheLifeNotImpl );
} }
break; break;
...@@ -4070,22 +4101,26 @@ void Content::getResourceOptions( ...@@ -4070,22 +4101,26 @@ void Content::getResourceOptions(
// instead of SC_NOT_IMPLEMENTED or SC_METHOD_NOT_ALLOWED. // instead of SC_NOT_IMPLEMENTED or SC_METHOD_NOT_ALLOWED.
// So check if this is an available resource, or a real 'Not Found' event. // So check if this is an available resource, or a real 'Not Found' event.
sal_uInt32 nLifeTime = m_nOptsCacheLifeNotFound; sal_uInt32 nLifeTime = m_nOptsCacheLifeNotFound;
if( isResourceAvailable( xEnv, rResAccess, rDAVOptions ) ) if( isResourceAvailable( xEnv, rResAccess, aDAVOptions ) )
{ {
SAL_WARN( "ucb.ucp.webdav", "OPTIONS - Got an SC_NOT_FOUND, but the URL <" << m_xIdentifier->getContentIdentifier() << "> resource exists" );
nLifeTime = m_nOptsCacheLifeNotImpl; nLifeTime = m_nOptsCacheLifeNotImpl;
} }
aStaticDAVOptionsCache.addDAVOptions( rDAVOptions, else
SAL_WARN( "ucb.ucp.webdav", "OPTIONS - SC_NOT_FOUND for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
nLifeTime ); nLifeTime );
SAL_WARN( "ucb.ucp.webdav", "OPTIONS - SC_NOT_FOUND for URL <" << m_xIdentifier->getContentIdentifier() << ">" );
} }
break; break;
default: default:
{ {
SAL_WARN( "ucb.ucp.webdav", "OPTIONS - DAV_HTTP_ERROR, for URL <" << m_xIdentifier->getContentIdentifier() << ">, HTTP error: "<< e.getStatus() ); SAL_WARN( "ucb.ucp.webdav", "OPTIONS - DAV_HTTP_ERROR, for URL <" << m_xIdentifier->getContentIdentifier() << ">, HTTP error: "<< e.getStatus()
rDAVOptions.setHttpResponseStatusCode( e.getStatus() ); << ", '" << e.getData() << "'" );
rDAVOptions.setHttpResponseStatusText( e.getData() ); aDAVOptions.setHttpResponseStatusCode( e.getStatus() );
aDAVOptions.setHttpResponseStatusText( e.getData() );
// cache it, so OPTIONS won't be called again, this URL does not support it // cache it, so OPTIONS won't be called again, this URL does not support it
aStaticDAVOptionsCache.addDAVOptions( rDAVOptions, aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
m_nOptsCacheLifeNotImpl ); m_nOptsCacheLifeNotImpl );
} }
break; break;
...@@ -4100,13 +4135,14 @@ void Content::getResourceOptions( ...@@ -4100,13 +4135,14 @@ void Content::getResourceOptions(
{ {
SAL_WARN( "ucb.ucp.webdav","OPTIONS - General DAVException (or max DAV_HTTP_REDIRECT reached) for URL <" << m_xIdentifier->getContentIdentifier() << ">, DAV ExceptionCode: " SAL_WARN( "ucb.ucp.webdav","OPTIONS - General DAVException (or max DAV_HTTP_REDIRECT reached) for URL <" << m_xIdentifier->getContentIdentifier() << ">, DAV ExceptionCode: "
<< e.getError() << ", HTTP error: "<< e.getStatus() ); << e.getError() << ", HTTP error: "<< e.getStatus() );
aStaticDAVOptionsCache.addDAVOptions( rDAVOptions, aStaticDAVOptionsCache.addDAVOptions( aDAVOptions,
m_nOptsCacheLifeNotImpl ); m_nOptsCacheLifeNotImpl );
} }
break; break;
} }
} }
} }
rDAVOptions = aDAVOptions;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment