diff -r 7b73058d782e -r cbbdf207e67e libidav/methods.c --- a/libidav/methods.c Fri Mar 18 19:54:36 2016 +0100 +++ b/libidav/methods.c Sat Mar 19 12:34:32 2016 +0100 @@ -846,7 +846,9 @@ s = S("\n"); ucx_buffer_write(s.ptr, 1, s.length, buf); - // TODO: cleanup namespace map + // cleanup namespace map + ucx_map_free_content(namespaces, free); + ucx_map_free(namespaces); return buf; } @@ -900,7 +902,7 @@ return s*n; } -CURLcode do_put_request(CURL *handle, char *lock, void *data, dav_read_func read_func, size_t length) { +CURLcode do_put_request(CURL *handle, char *lock, DavBool create, void *data, dav_read_func read_func, size_t length) { curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, NULL); curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L); @@ -909,7 +911,14 @@ if(lock) { char *url = NULL; curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); - char *ltheader = ucx_sprintf("If: <%s> (<%s>)", url, lock).ptr; + char *ltheader = NULL; + if(create) { + url = util_parent_path(url); + ltheader = ucx_sprintf("If: <%s> (<%s>)", url, lock).ptr; + free(url); + } else { + ltheader = ucx_sprintf("If: <%s> (<%s>)", url, lock).ptr; + } headers = curl_slist_append(headers, ltheader); free(ltheader); curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); @@ -942,6 +951,7 @@ if(buf) { ucx_buffer_free(buf); } + return ret; } @@ -974,7 +984,9 @@ if(lock) { char *url = NULL; curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); + url = util_parent_path(url); char *ltheader = ucx_sprintf("If: <%s> (<%s>)", url, lock).ptr; + free(url); headers = curl_slist_append(headers, ltheader); free(ltheader); curl_easy_setopt(handle, CURLOPT_HTTPHEADER, NULL);