From d74c81feee063e0afd70ba4359340f3f410e9cd5 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 12 Nov 2012 18:42:47 +0100 Subject: [PATCH] Owncloud: Add support for sending a cookie --- modules/csync_owncloud.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/csync_owncloud.c b/modules/csync_owncloud.c index 4a6375df8..892a501d3 100644 --- a/modules/csync_owncloud.c +++ b/modules/csync_owncloud.c @@ -507,7 +507,7 @@ static void request_created_hook(ne_request *req, void *userdata, if( !req ) return; if(dav_session.session_key) { - /* DEBUG_WEBDAV("Setting PHPSESSID to %s", dav_session.session_key); */ + DEBUG_WEBDAV("Setting PHPSESSID to %s", dav_session.session_key); ne_add_request_header(req, "Cookie", dav_session.session_key); } @@ -603,8 +603,6 @@ static int dav_connect(const char *base_url) { /* Hook called when a request is built. It sets the PHPSESSID header */ ne_hook_create_request( dav_session.ctx, request_created_hook, NULL ); - dav_session.session_key = NULL; - /* Proxy support */ proxystate = configureProxy( dav_session.ctx ); if( proxystate < 0 ) { @@ -2071,8 +2069,20 @@ csync_vio_method_t *vio_module_init(const char *method_name, const char *args, _authcb = cb; _connected = 0; /* triggers dav_connect to go through the whole neon setup */ + dav_session.session_key = NULL; + if( userdata ) { userdata_ptr = userdata; + if( *userdata_ptr && strlen( *userdata_ptr) && 0 == strcmp(*userdata_ptr, "Cookie=")) { + userdata_ptr++; + char *cookie = *userdata_ptr; + DEBUG_WEBDAV("Will use cookie given to us: %s", cookie); + userdata_ptr++; + dav_session.session_key = c_strdup( cookie ); + } else { + DEBUG_WEBDAV("No cookie given to us %s", *userdata_ptr); + } + if( *userdata_ptr && strlen( *userdata_ptr) ) dav_session.proxy_type = c_strdup( *userdata_ptr ); userdata_ptr++;