dav follows location header

Tue, 18 Mar 2014 11:48:22 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 18 Mar 2014 11:48:22 +0100
changeset 41
1c598ee0d3d9
parent 40
a95ee94b9204
child 42
6518b035a9df

dav follows location header

libidav/resource.c file | annotate | diff | comparison | revisions
libidav/webdav.c file | annotate | diff | comparison | revisions
--- 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);
--- 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);
 }
 

mercurial