[Libreoffice-commits] core.git: ucb/source
Giuseppe Castagno
giuseppe.castagno at acca-esse.eu
Thu Jul 28 08:42:41 UTC 2016
ucb/source/ucp/webdav-neon/DAVSession.hxx | 5 +
ucb/source/ucp/webdav-neon/NeonSession.cxx | 106 +++++++++++++++++++++++++++++
ucb/source/ucp/webdav-neon/NeonSession.hxx | 6 +
3 files changed, 117 insertions(+)
New commits:
commit fa1b59710863b797d32273c58f6ab116d3ab5ad6
Author: Giuseppe Castagno <giuseppe.castagno at acca-esse.eu>
Date: Sat Jan 9 19:54:59 2016 +0100
tdf#101094 (2) OPTIONS: Add neon session implementation
Change-Id: I1032f552b8ee2a413fdbfbf414bd7b39d6cbe6e3
Reviewed-on: https://gerrit.libreoffice.org/27606
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/DAVSession.hxx b/ucb/source/ucp/webdav-neon/DAVSession.hxx
index 5434bdc..e6b7a1a 100644
--- a/ucb/source/ucp/webdav-neon/DAVSession.hxx
+++ b/ucb/source/ucp/webdav-neon/DAVSession.hxx
@@ -75,6 +75,11 @@ public:
// DAV methods
+ virtual void OPTIONS( const OUString & inPath,
+ DAVOptions& rOptions,
+ const DAVRequestEnvironment & rEnv )
+ throw( std::exception ) = 0;
+
// allprop & named
virtual void PROPFIND( const OUString & inPath,
const Depth inDepth,
diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx
index df3cd75..9d9741b 100644
--- a/ucb/source/ucp/webdav-neon/NeonSession.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx
@@ -840,6 +840,112 @@ bool NeonSession::UsesProxy()
return !m_aProxyName.isEmpty() ;
}
+void NeonSession::OPTIONS( const OUString & inPath,
+ DAVOptions & rOptions, // contains the name+values of every header
+ const DAVRequestEnvironment & rEnv )
+ throw( std::exception )
+{
+
+ osl::Guard< osl::Mutex > theGuard( m_aMutex );
+ SAL_INFO( "ucb.ucp.webdav", "OPTIONS - relative URL <" << inPath << ">" );
+
+ rOptions.reset();
+ int theRetVal = NE_OK;
+
+ Init( rEnv );
+
+ ne_request *req = ne_request_create(m_pHttpSession, "OPTIONS", OUStringToOString(
+ inPath, RTL_TEXTENCODING_UTF8 ).getStr());
+
+ theRetVal = ne_request_dispatch(req);
+
+ //check if http error is in the 200 class (no error)
+ if (theRetVal == NE_OK && ne_get_status(req)->klass != 2) {
+ theRetVal = NE_ERROR;
+ }
+
+ if ( theRetVal == NE_OK )
+ {
+ void *cursor = nullptr;
+ const char *name, *value;
+ while ( ( cursor = ne_response_header_iterate(
+ req, cursor, &name, &value ) ) != nullptr )
+ {
+ OUString aHeaderName( OUString::createFromAscii( name ).toAsciiLowerCase() );
+ OUString aHeaderValue( OUString::createFromAscii( value ) );
+
+ // display the single header
+ SAL_INFO( "ucb.ucp.webdav", "OPTIONS - received header: " << aHeaderName << ":" << aHeaderValue );
+
+ if ( aHeaderName == "allow" )
+ {
+ rOptions.setAllowedMethods( aHeaderValue );
+ }
+ else if ( aHeaderName == "dav" )
+ {
+ // check type of dav capability
+ // need to parse the value, token separator: ","
+ // see <http://tools.ietf.org/html/rfc4918#section-10.1>,
+ // <http://tools.ietf.org/html/rfc4918#section-18>,
+ // and <http://tools.ietf.org/html/rfc7230#section-3.2>
+ // we detect the class (1, 2 and 3), other elements (token, URL)
+ // are not used for now
+ // silly parser written using OUString, not very efficient
+ // but quick and esy to write...
+ sal_Int32 nFromIndex = 0;
+ sal_Int32 nNextIndex = 0;
+ while( ( nNextIndex = aHeaderValue.indexOf( ",", nFromIndex ) ) != -1 )
+ { // found a comma
+ // try to convert from nFromIndex to nNextIndex -1 in a number
+ // if this is 1 or 2 or 3, use for class setting
+ sal_Int32 nClass =
+ aHeaderValue.copy( nFromIndex, nNextIndex - nFromIndex ).toInt32();
+ switch( nClass )
+ {
+ case 1:
+ rOptions.setClass1();
+ break;
+ case 2:
+ rOptions.setClass2();
+ break;
+ case 3:
+ rOptions.setClass3();
+ break;
+ default:
+ ;
+ }
+ // next starting point
+ nFromIndex = nNextIndex + 1;
+ }
+ // check for last fragment
+ if ( nFromIndex < aHeaderValue.getLength() )
+ {
+ sal_Int32 nClass = aHeaderValue.copy( nFromIndex ).toInt32();
+ switch( nClass )
+ {
+ case 1:
+ rOptions.setClass1();
+ break;
+ case 2:
+ rOptions.setClass2();
+ break;
+ case 3:
+ rOptions.setClass3();
+ break;
+ default:
+ ;
+ }
+ }
+ }
+ }
+ rOptions.setResourceFound();
+ }
+
+ ne_request_destroy(req);
+
+ HandleError( theRetVal, inPath, rEnv );
+}
+
void NeonSession::PROPFIND( const OUString & inPath,
const Depth inDepth,
const std::vector< OUString > & inPropNames,
diff --git a/ucb/source/ucp/webdav-neon/NeonSession.hxx b/ucb/source/ucp/webdav-neon/NeonSession.hxx
index 6065128..05556d6 100644
--- a/ucb/source/ucp/webdav-neon/NeonSession.hxx
+++ b/ucb/source/ucp/webdav-neon/NeonSession.hxx
@@ -86,6 +86,12 @@ public:
const DAVRequestEnvironment & getRequestEnvironment() const
{ return m_aEnv; }
+ virtual void
+ OPTIONS( const OUString & inPath,
+ DAVOptions& rOptions, // contains the name+values
+ const DAVRequestEnvironment & rEnv )
+ throw( std::exception ) SAL_OVERRIDE;
+
// allprop & named
virtual void
PROPFIND( const OUString & inPath,
More information about the Libreoffice-commits
mailing list