# HG changeset patch # User Olaf Wintermann # Date 1707222571 -3600 # Node ID 673a803d220337d927d6ec0b7b109a4c01a3ccaf # Parent bff9833705659cc9b1efa80a1720825a291f8e64 fix session dup diff -r bff983370565 -r 673a803d2203 dav/config.c --- a/dav/config.c Thu Feb 01 10:41:39 2024 +0100 +++ b/dav/config.c Tue Feb 06 13:29:31 2024 +0100 @@ -569,7 +569,8 @@ sn->flags = dav_repository_get_flags(repo); sn->key = dav_context_get_key(ctx, repo->default_key.value.ptr); - curl_easy_setopt(sn->handle, CURLOPT_HTTPAUTH, repo->authmethods); + // TODO: reactivate + //curl_easy_setopt(sn->handle, CURLOPT_HTTPAUTH, repo->authmethods); curl_easy_setopt(sn->handle, CURLOPT_SSLVERSION, repo->ssl_version); if(repo->cert.value.ptr) { curl_easy_setopt(sn->handle, CURLOPT_CAINFO, repo->cert.value.ptr); diff -r bff983370565 -r 673a803d2203 dav/main.c --- a/dav/main.c Thu Feb 01 10:41:39 2024 +0100 +++ b/dav/main.c Tue Feb 06 13:29:31 2024 +0100 @@ -440,6 +440,7 @@ int depth = cmd_getoption(a, "recursive") ? -1 : 1; int ret = 0; + DavResource *ls = dav_query( sn, date ? LIST_QUERY_ORDER_BY_DATE : LIST_QUERY_ORDER_BY_NAME, diff -r bff983370565 -r 673a803d2203 libidav/session.c --- a/libidav/session.c Thu Feb 01 10:41:39 2024 +0100 +++ b/libidav/session.c Tue Feb 06 13:29:31 2024 +0100 @@ -114,6 +114,35 @@ return sn; } +DavSession* dav_session_clone(DavSession *sn) { + CURL *newhandle = curl_easy_duphandle(sn->handle); + + DavSession *newsn = malloc(sizeof(DavSession)); + memset(newsn, 0, sizeof(DavSession)); + newsn->mp = cxBasicMempoolCreate(DAV_SESSION_MEMPOOL_SIZE); + newsn->pathcache = cxHashMapCreate(sn->mp->allocator, CX_STORE_POINTERS, DAV_PATH_CACHE_SIZE); + newsn->key = sn->key; + newsn->errorstr = NULL; + newsn->error = DAV_OK; + newsn->flags = 0; + + newsn->handle = newhandle; + + newsn->base_url = cx_strdup_a(newsn->mp->allocator, cx_str(sn->base_url)).ptr; + newsn->auth_prompt = sn->auth_prompt; + newsn->authprompt_userdata = sn->authprompt_userdata; + newsn->logfunc = sn->logfunc; + newsn->get_progress = sn->get_progress; + newsn->put_progress = sn->put_progress; + newsn->progress_userdata = sn->progress_userdata; + + // add to context + dav_context_add_session(sn->context, newsn); + newsn->context = sn->context; + + return newsn; +} + void dav_session_set_auth(DavSession *sn, const char *user, const char *password) { if(user && password) { dav_session_set_auth_s(sn, cx_str(user), cx_str(password)); diff -r bff983370565 -r 673a803d2203 libidav/webdav.h --- a/libidav/webdav.h Thu Feb 01 10:41:39 2024 +0100 +++ b/libidav/webdav.h Tue Feb 06 13:29:31 2024 +0100 @@ -289,6 +289,7 @@ char *base_url, char *user, char *password); +DavSession* dav_session_clone(DavSession *sn); void dav_session_set_auth(DavSession *sn, const char *user, const char *password); void dav_session_set_auth_s(DavSession *sn, cxstring user, cxstring password); void dav_session_set_baseurl(DavSession *sn, char *base_url);