# HG changeset patch # User Olaf Wintermann # Date 1395139702 -3600 # Node ID 1c598ee0d3d9e8961ebc2a72729eb96ac0d2da22 # Parent a95ee94b92042b1dcef3d2cd5a91b6cf83a70ab6 dav follows location header diff -r a95ee94b9204 -r 1c598ee0d3d9 libidav/resource.c --- a/libidav/resource.c Mon Mar 17 18:42:01 2014 +0100 +++ b/libidav/resource.c Tue Mar 18 11:48:22 2014 +0100 @@ -43,7 +43,6 @@ #define xstreq(a,b) xmlStrEqual(BAD_CAST a, BAD_CAST b) DavResource* dav_resource_new(DavSession *sn, char *path) { - int plen = 0; char *url = util_path_to_url(sn, path); char *href = util_url_path(url); DavResource *res = dav_resource_new_href(sn, href); diff -r a95ee94b9204 -r 1c598ee0d3d9 libidav/webdav.c --- a/libidav/webdav.c Mon Mar 17 18:42:01 2014 +0100 +++ b/libidav/webdav.c Tue Mar 18 11:48:22 2014 +0100 @@ -144,12 +144,14 @@ return NULL; } DavSession *sn = malloc(sizeof(DavSession)); + sn->mp = ucx_mempool_new(1024); sn->key = NULL; sn->errorstr = NULL; sn->error = DAV_OK; sn->flags = 0; if(url.ptr[url.length - 1] == '/') { - sn->base_url = strdup(base_url); // TODO: mempool + sstr_t url = sstrdup_a(sn->mp->allocator, sstr(base_url)); + sn->base_url = url.ptr; } else { char *url_str = malloc(url.length + 2); memcpy(url_str, base_url, url.length); @@ -161,6 +163,7 @@ sn->handle = curl_easy_init(); //curl_easy_setopt(sn->handle, CURLOPT_VERBOSE, 1L); //curl_easy_setopt(sn->handle, CURLOPT_STDERR, stderr); + curl_easy_setopt(sn->handle, CURLOPT_FOLLOWLOCATION, 1L); // set proxy DavProxy *proxy = sstrprefix(url, S("https")) ? context->https_proxy @@ -187,8 +190,6 @@ // set url curl_easy_setopt(sn->handle, CURLOPT_URL, base_url); - sn->mp = ucx_mempool_new(1024); - context->sessions = ucx_list_append(context->sessions, sn); return sn; @@ -253,7 +254,6 @@ ucx_mempool_destroy(sn->mp); curl_easy_cleanup(sn->handle); - free(sn->base_url); free(sn); }