summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2016-01-09 19:54:59 +0100
committerGiuseppe Castagno <giuseppe.castagno@acca-esse.eu>2016-07-28 08:42:08 +0000
commitfa1b59710863b797d32273c58f6ab116d3ab5ad6 (patch)
tree61483ce29b440c9d633558f6177a7c474762e7ef
parent05676088e23a7da470ba5e574ddf03a29fb11c9a (diff)
tdf#101094 (2) OPTIONS: Add neon session implementation
Change-Id: I1032f552b8ee2a413fdbfbf414bd7b39d6cbe6e3 Reviewed-on: https://gerrit.libreoffice.org/27606 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Giuseppe Castagno <giuseppe.castagno@acca-esse.eu>
-rw-r--r--ucb/source/ucp/webdav-neon/DAVSession.hxx5
-rw-r--r--ucb/source/ucp/webdav-neon/NeonSession.cxx106
-rw-r--r--ucb/source/ucp/webdav-neon/NeonSession.hxx6
3 files changed, 117 insertions, 0 deletions
diff --git a/ucb/source/ucp/webdav-neon/DAVSession.hxx b/ucb/source/ucp/webdav-neon/DAVSession.hxx
index 5434bdcb66a7..e6b7a1ae3f16 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 df3cd7524c4a..9d9741bc5d10 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 60651287d4e6..05556d62f2d0 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,