Kaydet (Commit) f1005a88 authored tarafından Kurt Zenker's avatar Kurt Zenker

INTEGRATION: CWS ucbfixes01 (1.23.10); FILE MERGED

2007/04/20 14:17:57 kso 1.23.10.2: #i74980# - Upon redict on POST, do a GET.
2007/04/18 15:34:05 kso 1.23.10.1: #134089# - Never allow URLs with empty hostnames.
üst f00bcef1
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: DAVResourceAccess.cxx,v $ * $RCSfile: DAVResourceAccess.cxx,v $
* *
* $Revision: 1.23 $ * $Revision: 1.24 $
* *
* last change: $Author: rt $ $Date: 2007-01-29 14:34:47 $ * last change: $Author: kz $ $Date: 2007-05-10 13:06:49 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "com/sun/star/ucb/XWebDAVCommandEnvironment.hpp" #include "com/sun/star/ucb/XWebDAVCommandEnvironment.hpp"
#include "ucbhelper/simpleauthenticationrequest.hxx" #include "ucbhelper/simpleauthenticationrequest.hxx"
#include "comphelper/seekableinput.hxx"
#include "DAVAuthListenerImpl.hxx" #include "DAVAuthListenerImpl.hxx"
#include "DAVResourceAccess.hxx" #include "DAVResourceAccess.hxx"
...@@ -67,10 +68,10 @@ int DAVAuthListener_Impl::authenticate( ...@@ -67,10 +68,10 @@ int DAVAuthListener_Impl::authenticate(
{ {
if ( m_xEnv.is() ) if ( m_xEnv.is() )
{ {
uno::Reference< task::XInteractionHandler > xIH uno::Reference< task::XInteractionHandler > xIH
= m_xEnv->getInteractionHandler(); = m_xEnv->getInteractionHandler();
if ( xIH.is() ) if ( xIH.is() )
{ {
// #102871# - Supply username and password from previous try. // #102871# - Supply username and password from previous try.
// Password container service depends on this! // Password container service depends on this!
if ( inoutUserName.getLength() == 0 ) if ( inoutUserName.getLength() == 0 )
...@@ -90,12 +91,12 @@ int DAVAuthListener_Impl::authenticate( ...@@ -90,12 +91,12 @@ int DAVAuthListener_Impl::authenticate(
= xRequest->getSelection(); = xRequest->getSelection();
if ( xSelection.is() ) if ( xSelection.is() )
{ {
// Handler handled the request. // Handler handled the request.
uno::Reference< task::XInteractionAbort > xAbort( uno::Reference< task::XInteractionAbort > xAbort(
xSelection.get(), uno::UNO_QUERY ); xSelection.get(), uno::UNO_QUERY );
if ( !xAbort.is() ) if ( !xAbort.is() )
{ {
const rtl::Reference< const rtl::Reference<
ucbhelper::InteractionSupplyAuthentication > & xSupp ucbhelper::InteractionSupplyAuthentication > & xSupp
= xRequest->getAuthenticationSupplier(); = xRequest->getAuthenticationSupplier();
...@@ -108,11 +109,11 @@ int DAVAuthListener_Impl::authenticate( ...@@ -108,11 +109,11 @@ int DAVAuthListener_Impl::authenticate(
m_aPrevPassword = outPassWord; m_aPrevPassword = outPassWord;
// go on. // go on.
return 0; return 0;
} }
}
} }
} }
}
// Abort. // Abort.
return -1; return -1;
} }
...@@ -169,32 +170,32 @@ void DAVResourceAccess::OPTIONS( ...@@ -169,32 +170,32 @@ void DAVResourceAccess::OPTIONS(
{ {
initialize(); initialize();
sal_Bool bRetry; bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = false;
try try
{ {
DAVRequestHeaders aHeaders; DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv, getUserRequestHeaders( xEnv,
getRequestURI(), getRequestURI(),
rtl::OUString::createFromAscii( rtl::OUString::createFromAscii(
"OPTIONS" ), "OPTIONS" ),
aHeaders ); aHeaders );
m_xSession->OPTIONS( getRequestURI(), m_xSession->OPTIONS( getRequestURI(),
rCapabilities, rCapabilities,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders) ); aHeaders) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
bRetry = handleException( e ); bRetry = handleException( e );
if ( !bRetry ) if ( !bRetry )
throw; throw;
} }
} }
while ( bRetry ); while ( bRetry );
} }
...@@ -209,34 +210,34 @@ void DAVResourceAccess::PROPFIND( ...@@ -209,34 +210,34 @@ void DAVResourceAccess::PROPFIND(
{ {
initialize(); initialize();
sal_Bool bRetry; bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = false;
try try
{ {
DAVRequestHeaders aHeaders; DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv, getUserRequestHeaders( xEnv,
getRequestURI(), getRequestURI(),
rtl::OUString::createFromAscii( rtl::OUString::createFromAscii(
"PROPFIND" ), "PROPFIND" ),
aHeaders ); aHeaders );
m_xSession->PROPFIND( getRequestURI(), m_xSession->PROPFIND( getRequestURI(),
nDepth, nDepth,
rPropertyNames, rPropertyNames,
rResources, rResources,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders ) ); aHeaders ) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
bRetry = handleException( e ); bRetry = handleException( e );
if ( !bRetry ) if ( !bRetry )
throw; throw;
} }
} }
while ( bRetry ); while ( bRetry );
} }
...@@ -250,33 +251,33 @@ void DAVResourceAccess::PROPFIND( ...@@ -250,33 +251,33 @@ void DAVResourceAccess::PROPFIND(
{ {
initialize(); initialize();
sal_Bool bRetry; bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = false;
try try
{ {
DAVRequestHeaders aHeaders; DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv, getUserRequestHeaders( xEnv,
getRequestURI(), getRequestURI(),
rtl::OUString::createFromAscii( rtl::OUString::createFromAscii(
"PROPFIND" ), "PROPFIND" ),
aHeaders ); aHeaders );
m_xSession->PROPFIND( getRequestURI(), m_xSession->PROPFIND( getRequestURI(),
nDepth, nDepth,
rResInfo, rResInfo,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders ) ) ; aHeaders ) ) ;
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
bRetry = handleException( e ); bRetry = handleException( e );
if ( !bRetry ) if ( !bRetry )
throw; throw;
} }
} }
while ( bRetry ); while ( bRetry );
} }
...@@ -289,32 +290,32 @@ void DAVResourceAccess::PROPPATCH( ...@@ -289,32 +290,32 @@ void DAVResourceAccess::PROPPATCH(
{ {
initialize(); initialize();
sal_Bool bRetry; bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = false;
try try
{ {
DAVRequestHeaders aHeaders; DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv, getUserRequestHeaders( xEnv,
getRequestURI(), getRequestURI(),
rtl::OUString::createFromAscii( rtl::OUString::createFromAscii(
"PROPPATCH" ), "PROPPATCH" ),
aHeaders ); aHeaders );
m_xSession->PROPPATCH( getRequestURI(), m_xSession->PROPPATCH( getRequestURI(),
rValues, rValues,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders ) ); aHeaders ) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
bRetry = handleException( e ); bRetry = handleException( e );
if ( !bRetry ) if ( !bRetry )
throw; throw;
} }
} }
while ( bRetry ); while ( bRetry );
} }
...@@ -328,26 +329,25 @@ void DAVResourceAccess::HEAD( ...@@ -328,26 +329,25 @@ void DAVResourceAccess::HEAD(
{ {
initialize(); initialize();
sal_Bool bRetry; bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = false;
try try
{ {
DAVRequestHeaders aHeaders; DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv, getUserRequestHeaders( xEnv,
getRequestURI(), getRequestURI(),
rtl::OUString::createFromAscii( "HEAD" ), rtl::OUString::createFromAscii( "HEAD" ),
aHeaders ); aHeaders );
m_xSession->HEAD( getRequestURI(), m_xSession->HEAD( getRequestURI(),
rHeaderNames, rHeaderNames,
rResource, rResource,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders ) ); aHeaders ) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
...@@ -367,30 +367,30 @@ uno::Reference< io::XInputStream > DAVResourceAccess::GET( ...@@ -367,30 +367,30 @@ uno::Reference< io::XInputStream > DAVResourceAccess::GET(
initialize(); initialize();
uno::Reference< io::XInputStream > xStream; uno::Reference< io::XInputStream > xStream;
sal_Bool bRetry; bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = false;
try try
{ {
DAVRequestHeaders aHeaders; DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv, getUserRequestHeaders( xEnv,
getRequestURI(), getRequestURI(),
rtl::OUString::createFromAscii( "GET" ), rtl::OUString::createFromAscii( "GET" ),
aHeaders ); aHeaders );
xStream = m_xSession->GET( getRequestURI(), xStream = m_xSession->GET( getRequestURI(),
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders ) ); aHeaders ) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
bRetry = handleException( e ); bRetry = handleException( e );
if ( !bRetry ) if ( !bRetry )
throw; throw;
} }
} }
while ( bRetry ); while ( bRetry );
...@@ -405,31 +405,31 @@ void DAVResourceAccess::GET( ...@@ -405,31 +405,31 @@ void DAVResourceAccess::GET(
{ {
initialize(); initialize();
sal_Bool bRetry; bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = false;
try try
{ {
DAVRequestHeaders aHeaders; DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv, getUserRequestHeaders( xEnv,
getRequestURI(), getRequestURI(),
rtl::OUString::createFromAscii( "GET" ), rtl::OUString::createFromAscii( "GET" ),
aHeaders ); aHeaders );
m_xSession->GET( getRequestURI(), m_xSession->GET( getRequestURI(),
rStream, rStream,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders ) ); aHeaders ) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
bRetry = handleException( e ); bRetry = handleException( e );
if ( !bRetry ) if ( !bRetry )
throw; throw;
} }
} }
while ( bRetry ); while ( bRetry );
} }
...@@ -444,25 +444,25 @@ uno::Reference< io::XInputStream > DAVResourceAccess::GET( ...@@ -444,25 +444,25 @@ uno::Reference< io::XInputStream > DAVResourceAccess::GET(
initialize(); initialize();
uno::Reference< io::XInputStream > xStream; uno::Reference< io::XInputStream > xStream;
sal_Bool bRetry; bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = false;
try try
{ {
DAVRequestHeaders aHeaders; DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv, getUserRequestHeaders( xEnv,
getRequestURI(), getRequestURI(),
rtl::OUString::createFromAscii( "GET" ), rtl::OUString::createFromAscii( "GET" ),
aHeaders ); aHeaders );
xStream = m_xSession->GET( getRequestURI(), xStream = m_xSession->GET( getRequestURI(),
rHeaderNames, rHeaderNames,
rResource, rResource,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders ) ); aHeaders ) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
...@@ -486,26 +486,26 @@ void DAVResourceAccess::GET( ...@@ -486,26 +486,26 @@ void DAVResourceAccess::GET(
{ {
initialize(); initialize();
sal_Bool bRetry; bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = false;
try try
{ {
DAVRequestHeaders aHeaders; DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv, getUserRequestHeaders( xEnv,
getRequestURI(), getRequestURI(),
rtl::OUString::createFromAscii( "GET" ), rtl::OUString::createFromAscii( "GET" ),
aHeaders ); aHeaders );
m_xSession->GET( getRequestURI(), m_xSession->GET( getRequestURI(),
rStream, rStream,
rHeaderNames, rHeaderNames,
rResource, rResource,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders ) ); aHeaders ) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
...@@ -517,6 +517,34 @@ void DAVResourceAccess::GET( ...@@ -517,6 +517,34 @@ void DAVResourceAccess::GET(
while ( bRetry ); while ( bRetry );
} }
//=========================================================================
namespace {
void resetInputStream( const uno::Reference< io::XInputStream > & rStream )
throw( DAVException )
{
try
{
uno::Reference< io::XSeekable > xSeekable(
rStream, uno::UNO_QUERY );
if ( xSeekable.is() )
{
xSeekable->seek( 0 );
return;
}
}
catch ( lang::IllegalArgumentException const & )
{
}
catch ( io::IOException const & )
{
}
throw DAVException( DAVException::DAV_INVALID_ARG );
}
} // namespace
//========================================================================= //=========================================================================
void DAVResourceAccess::PUT( void DAVResourceAccess::PUT(
const uno::Reference< io::XInputStream > & rStream, const uno::Reference< io::XInputStream > & rStream,
...@@ -525,38 +553,45 @@ void DAVResourceAccess::PUT( ...@@ -525,38 +553,45 @@ void DAVResourceAccess::PUT(
{ {
initialize(); initialize();
sal_Bool bRetry; // Make stream seekable, if it not. Needed, if request must be retried.
uno::Reference< io::XInputStream > xSeekableStream
= comphelper::OSeekableInputWrapper::CheckSeekableCanWrap(
rStream, m_xSMgr );
bool bRetry = false;
do do
{ {
bRetry = sal_False; if ( bRetry )
try resetInputStream( xSeekableStream );
{
DAVRequestHeaders aHeaders; bRetry = false;
getUserRequestHeaders( xEnv, try
getRequestURI(), {
rtl::OUString::createFromAscii( "PUT" ), DAVRequestHeaders aHeaders;
aHeaders ); getUserRequestHeaders( xEnv,
getRequestURI(),
m_xSession->PUT( getRequestURI(), rtl::OUString::createFromAscii( "PUT" ),
rStream, aHeaders );
DAVRequestEnvironment(
getRequestURI(), m_xSession->PUT( getRequestURI(),
new DAVAuthListener_Impl( xEnv ), xSeekableStream,
aHeaders ) ); DAVRequestEnvironment(
} getRequestURI(),
catch ( DAVException & e ) new DAVAuthListener_Impl( xEnv ),
{ aHeaders ) );
bRetry = handleException( e ); }
if ( !bRetry ) catch ( DAVException & e )
throw; {
} bRetry = handleException( e );
if ( !bRetry )
throw;
}
} }
while ( bRetry ); while ( bRetry );
} }
//========================================================================= //=========================================================================
uno::Reference< uno::Reference< io::XInputStream > DAVResourceAccess::POST(
io::XInputStream > DAVResourceAccess::POST(
const rtl::OUString & rContentType, const rtl::OUString & rContentType,
const rtl::OUString & rReferer, const rtl::OUString & rReferer,
const uno::Reference< io::XInputStream > & rInputStream, const uno::Reference< io::XInputStream > & rInputStream,
...@@ -565,34 +600,50 @@ uno::Reference< ...@@ -565,34 +600,50 @@ uno::Reference<
{ {
initialize(); initialize();
// Make stream seekable, if it not. Needed, if request must be retried.
uno::Reference< io::XInputStream > xSeekableStream
= comphelper::OSeekableInputWrapper::CheckSeekableCanWrap(
rInputStream, m_xSMgr );
uno::Reference< io::XInputStream > xStream; uno::Reference< io::XInputStream > xStream;
sal_Bool bRetry; bool bRetry = false;
do do
{ {
bRetry = sal_False; if ( bRetry )
try {
{ resetInputStream( xSeekableStream );
DAVRequestHeaders aHeaders; bRetry = false;
getUserRequestHeaders( xEnv, }
getRequestURI(),
rtl::OUString::createFromAscii( "POST" ), try
aHeaders ); {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii( "POST" ),
aHeaders );
xStream = m_xSession->POST( getRequestURI(), xStream = m_xSession->POST( getRequestURI(),
rContentType, rContentType,
rReferer, rReferer,
rInputStream, xSeekableStream,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders ) ); aHeaders ) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
bRetry = handleException( e ); bRetry = handleException( e );
if ( !bRetry ) if ( !bRetry )
throw; throw;
}
if ( e.getError() == DAVException::DAV_HTTP_REDIRECT )
{
// #i74980# - Upon POST redirect, do a GET.
return GET( xEnv );
}
}
} }
while ( bRetry ); while ( bRetry );
...@@ -611,34 +662,51 @@ void DAVResourceAccess::POST( ...@@ -611,34 +662,51 @@ void DAVResourceAccess::POST(
{ {
initialize(); initialize();
sal_Bool bRetry; // Make stream seekable, if it not. Needed, if request must be retried.
uno::Reference< io::XInputStream > xSeekableStream
= comphelper::OSeekableInputWrapper::CheckSeekableCanWrap(
rInputStream, m_xSMgr );
bool bRetry = false;
do do
{ {
bRetry = sal_False; if ( bRetry )
try {
{ resetInputStream( xSeekableStream );
DAVRequestHeaders aHeaders; bRetry = false;
getUserRequestHeaders( xEnv, }
getRequestURI(),
rtl::OUString::createFromAscii( "POST" ), try
aHeaders ); {
DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv,
getRequestURI(),
rtl::OUString::createFromAscii( "POST" ),
aHeaders );
m_xSession->POST( getRequestURI(), m_xSession->POST( getRequestURI(),
rContentType, rContentType,
rReferer, rReferer,
rInputStream, xSeekableStream,
rOutputStream, rOutputStream,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders ) ); aHeaders ) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
bRetry = handleException( e ); bRetry = handleException( e );
if ( !bRetry ) if ( !bRetry )
throw; throw;
}
if ( e.getError() == DAVException::DAV_HTTP_REDIRECT )
{
// #i74980# - Upon POST redirect, do a GET.
GET( rOutputStream, xEnv );
return;
}
}
} }
while ( bRetry ); while ( bRetry );
} }
...@@ -650,30 +718,30 @@ void DAVResourceAccess::MKCOL( ...@@ -650,30 +718,30 @@ void DAVResourceAccess::MKCOL(
{ {
initialize(); initialize();
sal_Bool bRetry; bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = false;
try try
{ {
DAVRequestHeaders aHeaders; DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv, getUserRequestHeaders( xEnv,
getRequestURI(), getRequestURI(),
rtl::OUString::createFromAscii( "MKCOL" ), rtl::OUString::createFromAscii( "MKCOL" ),
aHeaders ); aHeaders );
m_xSession->MKCOL( getRequestURI(), m_xSession->MKCOL( getRequestURI(),
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders ) ); aHeaders ) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
bRetry = handleException( e ); bRetry = handleException( e );
if ( !bRetry ) if ( !bRetry )
throw; throw;
} }
} }
while ( bRetry ); while ( bRetry );
} }
...@@ -688,32 +756,32 @@ void DAVResourceAccess::COPY( ...@@ -688,32 +756,32 @@ void DAVResourceAccess::COPY(
{ {
initialize(); initialize();
sal_Bool bRetry; bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = false;
try try
{ {
DAVRequestHeaders aHeaders; DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv, getUserRequestHeaders( xEnv,
getRequestURI(), getRequestURI(),
rtl::OUString::createFromAscii( "COPY" ), rtl::OUString::createFromAscii( "COPY" ),
aHeaders ); aHeaders );
m_xSession->COPY( rSourcePath, m_xSession->COPY( rSourcePath,
rDestinationURI, rDestinationURI,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders ), aHeaders ),
bOverwrite ); bOverwrite );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
bRetry = handleException( e ); bRetry = handleException( e );
if ( !bRetry ) if ( !bRetry )
throw; throw;
} }
} }
while ( bRetry ); while ( bRetry );
} }
...@@ -728,69 +796,68 @@ void DAVResourceAccess::MOVE( ...@@ -728,69 +796,68 @@ void DAVResourceAccess::MOVE(
{ {
initialize(); initialize();
sal_Bool bRetry; bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = false;
try try
{ {
DAVRequestHeaders aHeaders; DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv, getUserRequestHeaders( xEnv,
getRequestURI(), getRequestURI(),
rtl::OUString::createFromAscii( "MOVE" ), rtl::OUString::createFromAscii( "MOVE" ),
aHeaders ); aHeaders );
m_xSession->MOVE( rSourcePath, m_xSession->MOVE( rSourcePath,
rDestinationURI, rDestinationURI,
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders ), aHeaders ),
bOverwrite ); bOverwrite );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
bRetry = handleException( e ); bRetry = handleException( e );
if ( !bRetry ) if ( !bRetry )
throw; throw;
} }
} }
while ( bRetry ); while ( bRetry );
} }
//========================================================================= //=========================================================================
void DAVResourceAccess::DESTROY( void DAVResourceAccess::DESTROY(
const uno::Reference< const uno::Reference< ucb::XCommandEnvironment > & xEnv )
ucb::XCommandEnvironment > & xEnv )
throw( DAVException ) throw( DAVException )
{ {
initialize(); initialize();
sal_Bool bRetry; bool bRetry;
do do
{ {
bRetry = sal_False; bRetry = false;
try try
{ {
DAVRequestHeaders aHeaders; DAVRequestHeaders aHeaders;
getUserRequestHeaders( xEnv, getUserRequestHeaders( xEnv,
getRequestURI(), getRequestURI(),
rtl::OUString::createFromAscii( rtl::OUString::createFromAscii(
"DESTROY" ), "DESTROY" ),
aHeaders ); aHeaders );
m_xSession->DESTROY( getRequestURI(), m_xSession->DESTROY( getRequestURI(),
DAVRequestEnvironment( DAVRequestEnvironment(
getRequestURI(), getRequestURI(),
new DAVAuthListener_Impl( xEnv ), new DAVAuthListener_Impl( xEnv ),
aHeaders ) ); aHeaders ) );
} }
catch ( DAVException & e ) catch ( DAVException & e )
{ {
bRetry = handleException( e ); bRetry = handleException( e );
if ( !bRetry ) if ( !bRetry )
throw; throw;
} }
} }
while ( bRetry ); while ( bRetry );
} }
...@@ -836,9 +903,15 @@ void DAVResourceAccess::initialize() ...@@ -836,9 +903,15 @@ void DAVResourceAccess::initialize()
{ {
NeonUri aURI( m_aURL ); NeonUri aURI( m_aURL );
rtl::OUString aPath( aURI.GetPath() ); rtl::OUString aPath( aURI.GetPath() );
/* #134089# - Check URI */
if ( !aPath.getLength() ) if ( !aPath.getLength() )
throw DAVException( DAVException::DAV_INVALID_ARG ); throw DAVException( DAVException::DAV_INVALID_ARG );
/* #134089# - Check URI */
if ( !aURI.GetHost().getLength() )
throw DAVException( DAVException::DAV_INVALID_ARG );
if ( !m_xSession.is() || !m_xSession->CanUse( m_aURL ) ) if ( !m_xSession.is() || !m_xSession->CanUse( m_aURL ) )
{ {
m_xSession.clear(); m_xSession.clear();
...@@ -935,24 +1008,19 @@ sal_Bool DAVResourceAccess::detectRedirectCycle( ...@@ -935,24 +1008,19 @@ sal_Bool DAVResourceAccess::detectRedirectCycle(
//========================================================================= //=========================================================================
sal_Bool DAVResourceAccess::handleException( DAVException & e ) sal_Bool DAVResourceAccess::handleException( DAVException & e )
throw ( DAVException )
{ {
switch ( e.getError() ) switch ( e.getError() )
{ {
case DAVException::DAV_HTTP_REDIRECT: case DAVException::DAV_HTTP_REDIRECT:
try if ( !detectRedirectCycle( e.getData() ) )
{ {
if ( !detectRedirectCycle( e.getData() ) ) // set new URL and path.
{ setURL( e.getData() );
// set new URL and path. initialize();
setURL( e.getData() ); return sal_True;
initialize(); }
return sal_True; return sal_False;
}
}
catch( DAVException const & )
{
}
return sal_False;
default: default:
return sal_False; // Abort return sal_False; // Abort
......
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