webdav: Allow to save documents again, after locking is implemented.
We need to extend PUT method with lock token in 'If' header, so that it does not fail on a resource locked by us. Change-Id: I82a9e3303a34607dba8bb874d1eb0fac23b9f11d
This commit is contained in:
@@ -29,10 +29,12 @@ namespace http_dav_ucp
|
||||
SerfPutReqProcImpl::SerfPutReqProcImpl( const char* inPath,
|
||||
const DAVRequestHeaders& inRequestHeaders,
|
||||
const char* inData,
|
||||
apr_size_t inDataLen )
|
||||
apr_size_t inDataLen,
|
||||
const OUString& sToken )
|
||||
: SerfRequestProcessorImpl( inPath, inRequestHeaders )
|
||||
, mpData( inData )
|
||||
, mnDataLen( inDataLen )
|
||||
, msToken( sToken )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -64,6 +66,11 @@ serf_bucket_t * SerfPutReqProcImpl::createSerfRequestBucket( serf_request_t * in
|
||||
// general header fields provided by caller
|
||||
setRequestHeaders( hdrs_bkt );
|
||||
|
||||
// 'If' header with token, so that we can save document locked by us
|
||||
const OString sIfHeader( "<" + OString(getPathStr()) + "> (<" + OUStringToOString(
|
||||
msToken, RTL_TEXTENCODING_UTF8) + ">)" );
|
||||
serf_bucket_headers_set( hdrs_bkt, "If", sIfHeader.getStr() );
|
||||
|
||||
return req_bkt;
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,8 @@ public:
|
||||
SerfPutReqProcImpl( const char* inPath,
|
||||
const DAVRequestHeaders& inRequestHeaders,
|
||||
const char* inData,
|
||||
apr_size_t inDataLen );
|
||||
apr_size_t inDataLen,
|
||||
const OUString& sToken );
|
||||
|
||||
|
||||
virtual ~SerfPutReqProcImpl();
|
||||
@@ -49,7 +50,7 @@ protected:
|
||||
private:
|
||||
const char* mpData;
|
||||
apr_size_t mnDataLen;
|
||||
|
||||
OUString msToken;
|
||||
};
|
||||
|
||||
} // namespace http_dav_ucp
|
||||
|
@@ -203,10 +203,16 @@ bool SerfRequestProcessor::processPut( const char* inData,
|
||||
apr_size_t inDataLen,
|
||||
apr_status_t& outSerfStatus )
|
||||
{
|
||||
// get the lock from lock store
|
||||
const OUString sToken(
|
||||
apr_environment::AprEnv::getAprEnv()->getSerfLockStore()->getLockToken(
|
||||
OUString::createFromAscii(mPathStr)) );
|
||||
|
||||
mpProcImpl = new SerfPutReqProcImpl( mPathStr,
|
||||
mrSerfSession.getRequestEnvironment().m_aRequestHeaders,
|
||||
inData,
|
||||
inDataLen );
|
||||
inDataLen,
|
||||
sToken );
|
||||
outSerfStatus = runProcessor();
|
||||
|
||||
return outSerfStatus == APR_SUCCESS;
|
||||
|
Reference in New Issue
Block a user